The game file that needs to be imported and loaded for this session is 5961_04_16.stencyl
.
Ensure that the Health
behavior is being displayed. It currently contains a single event called Countdown expired
. Now perform the following steps:
RestartLevel
(note the capitalization and that there no spaces).200
into the textbox.175
in the textbox, as shown in the following screenshot:We've created a
Custom Event called Relocate monkey
. Custom events allow us to create a set of instructions that will be started by a unique trigger that we can specify.
The behaviors we have created so far rely on built-in events, such as when the value of an attribute is less than a specified number, or when actors belonging to the specified groups collide with each other. Our new custom event will listen out for the triggering of an event called RestartLevel
, and we'll be creating an instruction to trigger that event in the next section, Time for action – triggering the custom event.
Once our custom event has been triggered, it will execute the instructions inside the when RestartLevel happens
block. In this case, the instructions specify a new x
and y
position for the monkey, the actor will be placed right back where it started.
How did we know which numbers to specify for the x
and y
positions? If we open up the jungle scene in the Scene Designer, we can find out the start position of the monkey by clicking on the monkey actor in the scene and looking down to the lower left-hand corner of the Stencyl window, where we will see the coordinates of the currently selected actor, as shown in the following screenshot:
3.12.136.186