The game file to import and load for this session is 5961_06_04.stencyl
.
1
.Lives remaining:
(including the colon).We have modified the Collides with Enemies
event in the Manage Player Collisions
behavior so that it decrements the number of lives by one when the monkey collides with an enemy actor, and the new value of Lives
is shown in the debug console.
This was achieved by using the purple game attribute setter and getter blocks to set the value of the Lives
game attribute to its current value minus one. For example, if the value of Lives
is 3
when the event occurs, Lives
will be set to 3
minus 1
, which is 2
!
The print …
block was then used to display a message in the console, advising how many lives the player has remaining. We used the text & text
block to join the text Lives remaining:
together with the current value of the Lives
game attribute. The anything as text
block converts the numeric value of Lives
to text to ensure that it will display correctly.
Currently, the value of the Lives
attribute will continue to decrease below 0
, and the monkey will always be repositioned at its starting point. So our next task is to make something happen when the value of the Lives
game attribute reaches 0
!
From this point onwards, click-by-click steps to modify behaviors and to locate and place each instruction block will not be specified! Instead, an overview of the steps will be provided, and a screenshot of the completed event will be shown towards the end of each Time for action section.
The search facility, at the top of the instruction block palette, can be used to locate the required instruction block; simply click on the search box and type any part of the text that appears in the required block, then press the Enter key on the keyboard to display all the matching blocks in the block palette.
18.118.226.66