Game Development Reference
In-Depth Information
child objects have the same event (like the Fishpod objects do for the Create event), the child's
event overrides (replaces) the event of its parent. Try and make sure this makes sense as we will
continue to make full use of parenting in the remainder of this topic. You'll find that parenting is
a really powerful and useful concept once you understand it.
Now we need to create the correct behavior for the dying state object, as we haven't handled
that yet. We'll make Fishpod fall off the screen and then restart the game when he's outside the
room.
Adding Behaviors for the Dying State Object
1. Reopen obj_pod_dying and add a Create event.
2. Include a Speed Vertical action ( move tab) and type -15 into Vert. Speed . This will
push Fishpod up into the air slightly before he gets pulled down by gravity.
3. Include a Set Gravity action ( move tab). Type 270 into Direction (downward) and 2
into Gravity .
4. Include a Test Variable action ( control tab). Type facing into Variable , FACE_LEFT into
Value , and leave Operation set to equal to . This checks to see whether the character is
facing left and only performs the next action(s) if this is true.
5. Include a Change Sprite action ( main1 tab) and choose the spr_pod_jump_left sprite.
Leave the other settings as they are.
6. Repeat steps 4 and 5 testing for FACE_RIGHT and changing the Sprite to
spr_pod_jump_right .
7. Add an Other, Outside Room event and include a Restart Room action ( main1 tab)
without setting any Transition .
You might want to test out your dying state before continuing by placing a few hazards in
your test room and checking that they kill off Fishpod correctly. Remember that for lava you only
need to place instances of obj_lava_middle , but that they need to be in lengths of at least two
sections to work.
Goals
Our game won't provide much of a challenge without a goal, so the final addition we will make to
the game play will be to include some gold nuggets that Fishpod must collect in order to
complete each level. Exactly what a prehistoric fish-creature would do with gold is unclear, but
perhaps if he evolves into a hedgehog, then he could make them into rings. Once there are no
gold nuggets left on the current level, the game will automatically progress onto the next room.
Creating the Gold Object
Create a new object called obj_gold and give it the spr_gold sprite.
1.
2.
Add a Create event and include a Change Sprite action ( main1 tab). Set Sprite to
spr_gold , Subimage to random(30) , and Speed to 0.5 . This will set the gold sprite's start
frame to a random subimage between 0 and 29 (as there are 30 frames in the sprite)
and slow its animation down by half.
Reopen obj_pod and add a Collision event with obj_gold .
3.
4.
Include a Destroy Instance action ( main1 tab) and select Other . This will destroy the
gold as it is the other instance in the collision.
 
Search WWH ::




Custom Search