本範例展示在平台遊戲中加上傾斜跳板及移動跳板
建立新專案
a.      New
empty project
b.      Saveàplatform 6 – slopes
& moving platforms.capx
決定場景及遊戲畫面尺寸
a.      Layout1之Layout Size屬性:1280, 1024
b.      Project屬性:
Window Sizeà640, 480
Fullscreen in browseràoff
Window Sizeà640, 480
Fullscreen in browseràoff
Nameàplatform 6 – slopes
& moving platforms
在場景中加入跳板物件
a.      Insert
new Objectà
General/Sprite
Load
an image from a fileà選取block.png
b.      Nameàboard
c.       Sizeà240, 35
d.      Behaviors
Add
newàAttributes/Solid
Ctrl-drag複製5個board
適當調整6個board物件位置
加入玩家物件
a.      Insert
new Objectà
General/Sprite
Load
an image from a fileà選取gear.png
b.      Nameàplayer
c.       Sizeà48, 48
d.      Behaviors
Add
newàMovements/Platform
玩家掉落平台後自動重生
a.      切換到Event sheet
b.      Add
event
playeràSize &
Position/Is outside layout
c.       Add
action
Playerà Size &
Position/Set positionà130,
180
讓場景跟隨玩家捲動
a.      切換到Layout
b.      點選player
c.       Behaviors
Add
newàGeneral/Scroll
To
在場景上新增一個訊息圖層
a.      Layers面板/Add layer at
top
b.      NameàUI layer
c.       TransparentàYes
d.      Parallaxà0, 0   (同步移動圖層,前後圖層沒有視差)
e.      點選Layer 0
f.       
NameàPlayer
layer
加入訊息物件
a.      Insert
new Objectà
General/Text
b.      Nameàscore
c.       LayeràUI layer
d.      Horizontal
alignmentàLeft
e.      Vertical
alignmentàTop
f.       
Sizeà200,
22
取消預設使用方向鍵控制玩家物件
a.      點選player
b.      Behaviors/Platform/Default
controlsàNo
加入鍵盤物件
a.      Insert
new Objectà Input/Keyboard
設定按W鍵時使玩家跳躍
a.      切換到Event sheet
b.      Add
event
KeyboardàKey is downàW
c.       Add
action
playerà Platform/Simulation
controlàJump
設定按D鍵時使玩家右移
a.      Add
event
KeyboardàKey is downàD
b.      Add
action
playerà Platform/Simulation
controlàRight
設定按A鍵時使玩家右移
a.      Add
event
KeyboardàKey is downàA
b.      Add
action
playerà Platform/Simulation
controlàLeft
設定專案為全螢幕執行
a.      專案屬性
Fullscreen
in browseràCrop
b.      Layout1屬性
Unbounded
scrollingàYes
切換到Layout
適當調整2個board物件之大小、位置、角度,使其傾斜
在場景中加入移動跳板物件
a.     
Insert new Objectà General/Sprite
Load an image from a fileà選取block2.png
b.     
Nameàmovingboard
c.      
Sizeà150, 35
d.     
LayeràLayer 0
e.     
Behaviors
Add newàAttributes/Solid
f.       
Behaviors
Add newàMovements/Sine
屬性:
Periodà5
Magnitudeà150
屬性:
Periodà5
Magnitudeà150
 
 
 
 發表文章
發表文章
 
 
 
 
 
 
 
