本練習示範控制動態生成子彈物件之發射點
建立新專案
a.
New empty project
b.
Saveàspawn
position.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
調整子彈起始點
a.
雙擊Player物件,開啟Edit image視窗
b.
Set origin and image points,開啟Image points視窗
c.
Add image
point
d.
Quick assignàRight
e.
切換到Event sheet
f.
bullet, Layer
0, Image point 0à bullet, Layer 0,
Image point 1