Game Development Reference
In-Depth Information
Underground, Overground
Now that we have our standard platforms working, we can quite easily create behaviors for the
ledge platforms too. Ledges support Zool in the same way as normal, but he can jump up through
from underneath them and land on top. In the Sweet World, these ledge platforms are
represented by colorful square-shaped jellies, and there are a few of these around our test level.
However, they don't yet have the collision objects in place to collide with, so you'll need to do this
before we can start. Reopen
room_test
from the resources list and add instances of
obj_ledge
along the top surface of each block of jelly. The ledge collision objects are made up of a thin,
horizontal line, so be careful not to leave any stray ledge objects around. It's easier to see what
you are doing if you temporarily turn off the room grid by clicking on the grid icon on the toolbar.
There are two separate areas of jelly blocks that need ledges: one in the middle of the level and
the other on the far right-hand side. Once these are in place, there are not too many changes to
make to the actions.
Adding Support for Ledges to the Land and Air Zool State Objects
1.
Reopen
obj_zool_land
. Add a new
Collision
event with
obj_ledge
and include an
Exit
Event
action (
control
tab). We want Zool to ignore collisions with ledges when he is
walking on the landscape. However, because
obj_ledge
is “a kind of”
obj_solid
, the
obj_solid
collision event would have been called for collisions with
obj_ledge
as well.
Adding a collision event specifically for
obj_ledge
excludes ledges from the
obj_solid
collision event and makes nothing happen instead using the
Exit Event
action.
2.
Reopen
obj_zool_air
. Right-click on the
Collision
event with
obj_solid
to
Duplicate
Event
for a
Collision
with
obj_ledge
. Again, this creates a specific collision event for
obj_ledge
, which was previously handled by the collision event with
obj_solid
. Both
events are currently identical, but we will change that next.
3.
At the start of the list of actions, include a
Test Variable
action that checks if the
Variable
yprevious+18
is
larger than
other.y
. This compares the position directly
below Zool's feet in the previous step to see if it was below the y position of the ledge
platform (see Figure 4-7). If it is, then Zool must be approaching the platform from
below (rather than above) and the collision should be ignored.
4.
Immediately follow this with an
Exit Event
action to ignore the collision. This should
now be the second action in the list.
Search WWH ::
Custom Search