2014年1月22日 星期三

Construct 2教學:解析Platform 5 – fullscreen範例

本範例展示以全螢幕模式執行平台遊戲

建立新專案
a. New empty project
b. Saveàplatform 5 – fullscreen.capx

決定場景及遊戲畫面尺寸
a. Layout1之Layout Size屬性:1280, 1024
b. Project屬性:
Window Sizeà640, 480
Fullscreen in browseràoff
Nameàplatform 5 – fullscreen

在場景中加入跳板物件
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