The game file to import and load for this session is 5961_06_01.stencyl
.
Display Countdown
.10
into the x: textbox and also enter 10
into the y: textbox.COUNTDOWN:
(all uppercase, followed by a colon).When the game is played, we can now see in the upper-left corner of the screen, a countdown timer that represents the value of the Countdown
attribute as it is decremented each second.
First, we created a new Drawing
event, which we renamed to Display Countdown
, and then we added a draw text anything at ( x: 0 y: 0 )
block, which is used to display the specified text in the required location on the screen.
We set both the x: and y: coordinates for displaying the drawn text to 10
pixels, that is, 10 pixels from the left-hand side of the screen, and 10 pixels from the top of the screen.
The next task was to add some text blocks that enabled us to display an appropriate message along with the value of the Countdown
attribute. The text & text
block enables us to concatenate, or join together, two separate pieces of text. The Countdown
attribute is a number, so we used the anything as text
block to convert the value of the Countdown
attribute to text to ensure that it will be displayed correctly when the game is being played.
In practice, we could have just located the Countdown
attribute block in the Attributes section of the palette, and then dragged it straight into the text & text
block. However, it is best practice to correctly convert attributes to the appropriate type, as required by the instruction block. In our case, the number
attribute is being converted to text because it is being used in the text concatenation instruction block. If we needed to use a text value in a calculation, we would convert it to a number using an anything as number
block.
3.129.218.62