本練習示範動態生成子彈物件
建立新專案
a.
New empty project
b.
Saveàshooting
bullets.capx
決定場景及遊戲畫面尺寸
a.
Layout1之Layout Size屬性:640, 480
b.
Project屬性:
Window Sizeà640, 480
Fullscreen in browseràoff
Window Sizeà640, 480
Fullscreen in browseràoff
在場景中加入角色
a.
Insert new Objectà General/Sprite
b.
Load an image from a fileà選取player.png
c.
Renameàplayer
設定player行為
a.
Behaviors
b.
Add newàMovements/8
Direction
c.
Set angleàNo
加入滑鼠物件
a.
Insert new Objectà Input/Mouse
使player隨時面向滑鼠游標
a.
切換到Event sheet
b.
Add eventàSystemàGeneral/Every tick
c.
Add actionàplayeràAngle/Set angle toward positionàMouse.X,
Mouse.Y
限定player不能超出視窗
a.
點選player
b.
Behaviors
c.
Add newàGeneral/Bound
to layout
加入子彈物件(放置於Margins區)
a.
Insert new Objectà General/Sprite
b.
Load an image from a fileà選取bullet.png
c.
Renameàbullet
d.
Behavior
e.
Add newàMovements/Bullet
點擊滑鼠左鍵時發射子彈
a.
切換到Event sheet
b.
Add eventàMouseàOn clickàLeft, Clicked
c.
Add actionàplayeràMisc/Spawn another objectàbullet, Layer 0, Image point 0