Game Development Reference
In-Depth Information
Jump Up
Finishing off the remaining state objects should be pretty easy now, as there is nothing
particularly new to consider. Starting with obj_pod_jumping , we'll set the default behavior in the
Create event as usual, then handle the state transitions in Collision and Animation End events.
Adding a Create Event for the Jumping State Object
1. Reopen obj_pod_jumping and add a Create event.
2. Include a Speed Vertical action ( move tab) and type -24 into Vert. Speed . A negative
vertical speed moves the character up the screen, so this will launch Fishpod up into
the air.
3. Include a Set Gravity action ( move tab). Type 270 into Direction (downward) and 2
into Gravity . This tells Game Maker to increase the vertical speed by 2 in every step, as
if it was being pulled downward by the force of 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 right and only performs the next action(s) if this is true.
5. Include a Start Block action ( control tab). This indicates the start of a block of actions
grouped together so that all of them (not just the first) depend on the result of the
previous test.
6. Include a Change Sprite action ( main1 tab) and choose the spr_pod_jump_left sprite.
Leave the other settings as they are.
7. Include a Speed Horizontal action ( move tab) and set the Hor. Speed to -6 .
8. Include an End Block action ( control tab). This indicates the end of a block of actions
that are grouped together.
9. Repeat steps 4-8, testing for FACE_RIGHT , changing the Sprite to spr_pod_jump_right ,
and setting the Hor. Speed to 6 .
Our collision event for the jumping state object is actually going to be very similar to the
collision event for the walking object, so we'll copy it to save some time. Remember that we used
the direction variable as a parameter to the Move to Contact action, so the actions we're copying
automatically handle collisions in whatever direction Fishpod is travelling. However, we'll need
to change the Change Instance action from obj_pod_standing to obj_pod_falling and we'll
require an additional action in there that brings the jumping Fishpod to a halt.
Copying a Collision Event for the Jumping State Object
Reopen obj_pod_walking and select the Collision event with obj_platform (left-click on
it) so that the actions for this event are visible in the actions list.
1.
2.
Right-click anywhere in the actions list and choose Select All from the menu. Right-
click again and choose Copy .
Reopen obj_pod_jumping and add a Collision event with obj_platform .
3.
 
Search WWH ::




Custom Search