Game Development Reference
In-Depth Information
In order to provide more dynamism in the game, you will add some asteroids in
the spaceship trajectory, but instead of moving the spaceship, the asteroids will
move.
Follow the steps described in the ''Artist Entrance: Creating the Actors'' section
to import the image file named asteroid.jpg located into the Chapter5_Files
folder.
Create a new actor and double-click it to open the Actor Editor.
Edit the actor attributes with the parameters in Table 5-7.
Table 5-7. Asteroid Attributes
Name
Asteroid
Size/Width
64
Size/Height
64
Physics/Fixed Rotation
Checked
Physics/Restitution
0
Click the Images tab to display the image that you just imported, and drag and
drop asteroid.png into the actor.
Make the Asteroids Move
Drag and drop a Change Velocity behavior and change the settings to:
Direction: 270
Relative to: scene
Speed: random(100,300)
Create a new rule with the condition ''attribute''''asteroid.Position.Y''''<''''-60''.
Then drag and drop a Change Attribute behavior in the rule and change
Asteroid.Position.Y to 530. This will reposition the asteroid at the top of the
screen. But it would be boring to have the asteroid always on a same line at the
same speed. Drag and drop a second Change Attribute behavior and change
Asteroid.Position.X to random (0,320). Now the asteroid will appear at any place
on the X-axis. Now give the asteroid a variable speed. Select the Change
Velocity behavior that you just implemented by clicking once next to the
 
Search WWH ::




Custom Search