Game Development Reference
In-Depth Information
3.
Turn
Show Tiles
back off and place one instance of each of the 16 different
Ramps
group
objects (
obj_ramp_u1
to
obj_ramp_d8
), as shown in the bottom left panel of Figure 4-14.
Also, delete the unneeded platform instances underneath the ramp as shown.
Figure 4-14.
Adding ramp collision objects to the room
4.
Turn
Show Tiles
back on and scroll to the second ramp over on the far right of the
room.
5.
Carefully right-click on the two squares marked with blue crosses in the top right panel
of Figure 4-14 to delete the collision objects. Again, this will mark the boundaries of
the ramp for you when you turn the tiles off.
6.
Turn
Show Tiles
back off again and place instances of the first eight different
Ramps
group objects (
obj_ramp_u1
to
obj_ramp_u8
), as shown in the bottom right panel of
Figure 4-14. Also, delete the unneeded platform instances and add two extra to fill the
gap on the right-hand side of the ramp as shown.
Believe it or not, probably the hardest part of ramps is finished! If you play the game now,
you will see that you can already collide with ramps, as the hierarchy of parents means that all
these different ramp objects are eventually a kind of
obj_solid
. However, the general-purpose
obj_solid
collision events are not always suitable for ramps. The one in
obj_zool_land
simply
brings Zool to a halt on rising ramps, preventing him from walking up them. The sliding
mechanism in the collision event of
obj_zool_air
can cause Zool to slide uncontrollably down
falling ramps as well. Fortunately, we can simply add collision events between these state objects
and
obj_ramp
in order to handle this specific case differently from other solid objects.
Adding Specific Collision Events for Ramp Objects
1.
Reopen
obj_zool_land
and create a
Collision
event with
obj_ramp
. Include a
Set
Variable
action (
control
tab) that sets the
Variable
y
Relative
to
-speed
. This moves
Zool up by a distance equal to the speed he is traveling. The faster Zool is moving, the
further he may have moved inside the ramp during the collision, so the further he
needs to move up in order to be above the surface again (see Figure 4-15). This
method should work for angles up to and including 45 degrees.
Search WWH ::
Custom Search