2014年1月29日 星期三

Construct 2教學:解析Families範例

本範例展示Construct2之Families及事件表群組功能。
Families功能可讓家族成員擁有相同的物件變數,並共用事件處理,簡化事件處理作業。
而透過事件表群組,可以啟用或關閉整個群組的事件。



2014年1月22日 星期三

Construct 2教學:解析Platform 9 – jump thru範例

本範例展示在平台遊戲中加入可穿越的跳板

建立新專案
a.      New empty project
b.      Saveàplatform 9 – jump thru.capx

決定場景及遊戲畫面尺寸
a.      Layout1Layout Size屬性:1280, 1024
b.      Project屬性:
Window Size
à640, 480
Fullscreen in browser
àoff
Nameàplatform 9 – jump thru

在場景中加入跳板物件
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複製5board
適當調整6board物件位置

加入玩家物件
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
適當調整2board物件之大小、位置、角度,使其傾斜

在場景中加入移動跳板物件
a.      Insert new Objectà General/Sprite
b.      Load an image from a fileà選取block2.png
c.       Nameàmovingboard
d.      Sizeà150, 35
e.      LayeràLayer 0
f.        Behaviors
Add newàAttributes/Solid
g.      Behaviors
Add newàMovements/Sine
屬性:
Period
à5
Magnitude
à150

在場景上新增一個背景圖層
a.      Layers窗格/Add layer at top
b.      Move layer down調到最下層
c.       NameàBackground layer
d.      Background colorà204, 255, 255
e.      Parallaxà30, 30 (背景圖層與前面圖層移動視差30%)
f.        點選Player layer
g.      TransparentàYes

加入背景雲物件
a.      Insert new Objectà General/Sprite
b.      Nameàcloud
c.       LayeràBackground layer

Ctrl-drag複製4cloud
適當調整5cloud物件位置

設定按Space鍵時使畫面震動
a.      切換到Event sheet
b.      Add event
KeyboardàKey is downàSpace
c.       Add action
playerà ScrollTo/ShakeàMagnitude: 20, Duration: 0.4, Mode: Reducing magnitude

在場景中加入可穿越跳板物件
a.      Insert new Objectà General/Sprite
b.      Load an image from a fileà選取block2.png
Nameàjumpthru_board
Sizeà150, 35
LayeràPlayer layer
Opacity
à50
c.       Behaviors
Add newàAttributes/Jump-thru

Ctrl-drag複製2jumpthru_board

適當調整3jumpthru_board物件位置