Time for action – displaying a timer bar
The game file to import and load for this session is 5961_06_07.stencyl
.
Open the Score Management scene behavior and click on the Display HUD event.
In the when drawing event, right-click on the blue block that draws the text for the countdown timer and select Activate / Deactivate from the pop-up menu. Note that the block becomes faded.
Locate the draw rect at ( x: 0 y: 0 ) with ( w: 0 h: 0 ) instruction block in the palette, and insert it at the bottom of the when drawing event.
Click on the draw option in the newly inserted block and change it to fill.
Set both the x: and y: textboxes to
10
.Set the width (w:) to Countdown x
10
.Set the height (h:) to
10
.Ensure that the draw text … block and the fill rect at … block in the Display HUD event appear as shown in the following screenshot (the draw text LIVES: … block may look different if the earlier Have a go hero section was attempted):
Test the game!
What just happened?
We have created a timer bar that displays...