The game file to import and load for this session is 5961_05_06.stencyl
.
Health
actor behavior is displayed on the screen — click on the Dashboard tab, then click on Actor Behaviors, and double-click on the Health behavior's icon in the main panel.Show Angel
in the left-panel.ShowAngel
(note that there is no space).Manage Player Collisions
.Angel
in the text box.1
in the text box after the words Fade out for.1
in the text box after the words Fade in for.ShowAngel
(without spaces) in the textbox after the words trigger event.We have created a new custom event that switches to the monkey's Angel
animation, and is triggered when the countdown timer expires.
Our new custom event utilizes two new instruction blocks that we haven't used previously in our game. The first block that we introduced, in the Show Angel
event, disables the Jump and Run Movement
behavior, and we need to do this for two reasons: firstly, to prevent the player from continuing to control the monkey after the countdown has completed, and secondly, because the Jump and Run Movement
behavior continuously updates the monkey actor. If we failed to disable the movement behavior, it would automatically switch from the Angel
animation, straight back to one of the monkey's idle animations, before we even had time to see the Angel
animation onscreen! We also added a block to disable the Manage Player Collisions
behavior. When the countdown expires, we don't want the player to be able to collect any items, which could happen if the monkey was falling down towards one of the collectibles just as the countdown expired. Disabling this behavior will also prevent the monkey switching to the Angel
animation if it falls onto an enemy at the same moment the countdown expires.
Note that we don't need to reenable the behaviors at any time, because we are reloading the scene, which puts the behaviors back into their original enabled state.
Beneath the blocks to disable the behaviors, we introduced a switch animation to … for Self block. This block allows us to specify which animation we want to display, and we must supply the exact name of the animation, as it appears in the Animation Editor, including any capitalization and spaces.
The last step in creating our custom event was to add the instruction to fade out the scene and reload it. Reloading a scene puts it back to how it was right at the start of the game – it is completely reset as though it has never been played. This is the desired behavior for our game – when the countdown expires, the player must restart the scene. Don't worry; we'll be increasing the countdown to a more achievable value, later in the development process!
As we learned in Chapter 4, Creating Behaviors, custom events must be triggered so they can carry out the required actions. We placed the trigger instruction into the existing Countdown expired
event that checks every one second to determine if the countdown has reached zero. Originally, when the countdown reached zero, we simply killed the monkey, so we had to remove the kill Self
block before inserting the trigger event...
instruction.
We have used the switch animation to
instruction, which we found in the Animation subcategory of the Actor | Draw section of the palette.
There are several other instruction blocks in the Animation subcategory that can be used in behaviors to find information about and control animations associated with a particular actor.
Review these instruction blocks and consider how they might be useful when developing a game, remembering that right-clicking on any block and selecting View | Help will display some useful information.
3.138.35.193