Game Development Reference
In-Depth Information
12.
Include an
Exit Event
action (
control
tab).
13.
Include an
End Block
action (
control
tab) to mark the end of the grouped actions.
■
Note
Poisonous pansies may seem like an odd choice for a hazard, but they have an established gaming
heritage. They appeared in the underground caverns of Manic Miner in 1983—one of the first games to
popularize the platform game genre in the United Kingdom.
That should handle the automatic creation of lava platforms. Next, we need to make sure
that Fishpod restarts the level when he comes into contact with a hazard or goes off the edge of
the screen. We already have a parent object for all hazards, which should make this easier, but
things are a little more complicated for Fishpod. There are four different state objects that would
require their own collision event with the hazard object (all of the states apart from the dying
state object). So, rather than repeat ourselves four times, we will make
obj_pod
(the starting
Fishpod object) a parent of these four states and then just handle the one collision event between
obj_pod
and
obj_hazard
.
Adding Inherited Events to the Fishpod Object
1.
Open each of these state objects in turn:
obj_pod_standing
,
obj_pod_walking
,
obj_pod_jumping
, and
obj_pod_falling
(but not
obj_pod_dying
) and set the parent of
each one to be
obj_pod
.
Reopen
obj_pod
and add a
Collision
event with
obj_hazard
.
2.
Include a
Change Instance
action (
main1
tab) that changes into
obj_pod_dying
with
Perform Events
set to
yes.
3.
4.
Add an
Other, Outside Room
event.
5.
Include a
Test Variable
action (
control
tab) and check that the
y
Variable
is
larger than
0
. This means that the next action will only occur if Fishpod is lower than the top of the
screen (remember that y values start at 0 and increase down the screen). Gravity will
bring Fishpod back down again if he jumps off the top of the screen, so there is no
need to restart the level in this case.
Include a
Change Instance
action (
main1
tab) that changes into
obj_pod_dying
with
Perform Events
set to
yes
.
6.
■
Note
If you accidently try and make
obj_pod
a parent of
obj_pod
as well, then you will get an error
saying that this will create a loop in parents. It cannot be the parent of itself and we don't need it to be.
So although we have only added these
Collision
and
Outside Room
events to
obj_pod
, they
will also work for the four Fishpod state objects that have
obj_pod
as a parent. This is because
objects inherit events from their parents. The Fishpod state objects have no
Collision
event
defined with
obj_hazard
themselves, but their parent object (
obj_pod
) does, so they inherit this
event and all its actions. Likewise for the
Outside Room
event. However, when both parent and
Search WWH ::
Custom Search