Game Development Reference
In-Depth Information
Include a Repeat action ( control tab) to repeat the following action 4 Times . When an
enemy dies, it splits into four pieces, so we need to create four objects from one.
3.
4.
Immediately follow this with a Create Moving action ( main1 tab) that creates an
instance of obj_enemy_die at a Relative position of X = 0 Y = 0 , with a Speed of 4 and a
Direction of random(180) . Note that a random angle between 0 and 180 will range from
horizontally right through vertically up and to horizontally left.
5.
Include a (normal) Create Instance action that creates an instance of obj_splat at a
Relative position of X = 0 Y = 0 .
6.
Now add a Key Press , Letters , K event and include a Destroy Instance action to
destroy Self . We'll use this to test dying enemies before we've implemented Zool's
attacks.
Add a Create event for obj_enemy_die and include a Set Variable action ( control tab)
that sets the Variable sprite_index to global.die_sprite_index . Setting sprite_index
is equivalent to the first part of a Change Sprite action where you would normally
select the desired sprite from a drop-down menu. However, the drop-down menu
doesn't include variables and we want to set the sprite from a global variable
( die_sprite_index ), so this allows us to do that. You'll see where this variable comes
from a little later.
7.
8.
Take a quick peek at one of the enemy die sprites in the sprite resources ( Hazards
group). You can see that these sprites are not animations of an enemy dying, but
separate pieces of the enemy as if they had just exploded into pieces of a puzzle.
Include another Set Variable action that sets the Variable image_index to
random(image_number) . Setting image_index is equivalent to the second part of a
Change Sprite action where you set the subimage. The variable image_number holds the
total number of subimages in the current sprite, so we're just setting the subimage to
be a random image between 0 and image_number . The random function only returns
numbers small than the value in brackets.
9.
Include another Set Variable action that sets the Variable image_speed to 0 . Setting the
variable image_speed is equivalent to the third part of a Change Sprite action where
you set the animation speed of the sprite. So this stops the sprite from animating.
10.
Include a Set Gravity action ( move tab) that sets Gravity to 1 in Direction 270 (down).
At this point, you should have four actions for the Create event of obj_enemy_die , as
shown in Figure 5-4.
11.
 
Search WWH ::




Custom Search