Game Development Reference
In-Depth Information
Figure 5-4. The Create event of obj_enemy_die
12. Finally (for obj_enemy_die ), add an Other, Outside Room event and include a Destroy
Instance action ( main1 tab) to destroy Self . This makes sure the enemy pieces get
destroyed when they fall off screen.
13. Reopen obj_splat and add a Create event. Include a Set Variable action ( control tab)
that sets the Variable image_speed to 0.5 to slow down the animation speed.
14. Add an Other, Animation End event and include a Destroy Instance action ( main1
tab) to destroy the splat at the end of the animation.
15. Now we can actually create the Jelly enemy. Create a new object called obj_jelly
( Hazards group), give it the spr_jelly sprite, and make obj_enemy its parent.
16. Add a Create event and include a Set Variable action ( control tab) that sets the
Variable facing to FACE_LEFT . If you are using Game Maker Pro, then FACE_LEFT is a
constant that is available to use in all objects. If you are using the Lite version, then
FACE_LEFT is currently just a local variable to obj_zool , so you can't use it here. Don't
worry—just set the variable to -1 instead as it's the only time it is used for this object.
17. Add a Step, Step event and include a Speed Horizontal action ( move tab) that sets
Hor. Speed to facing*1.5 . In other words, give it a speed of +1.5 or -1.5 , depending on
the direction the jelly is facing. Next, we must consider the situations in which it
should change direction.
18. Include a Check Object action ( control tab) that checks for there NOT being a collision
with an instance of obj_platform at a Relative position of X = facing*16 and Y = 8 . This
means we're checking that there will be a platform to continue to support the Jelly if it
keeps moving in the direction it is traveling.
 
Search WWH ::




Custom Search