How to Create a Project Variable for Lives in MicroWorld EX
Your MicroWorld EX game needs a way to show how many lives are left. Traffic Dodge begins with three lives, and each time the player’s frog is hit by a traffic turtle, it loses a life. When the player has lost all three lives, the game is over.
In projects with a single page, you can just create a text box variable for lives. But the value of a text box variable exists on the page where it’s located. This means that you can’t carry over the value of a lives variable from a Level 1 page to a Level 2 page.
A project variable is a variable that exists everywhere in your game and whose value carries over from one page to another. To create a project variable that will be used to keep track of frog lives, enter the following command in the Command Center:
This command creates a new project variable with the name livesremain. The new project variable is visible on the Project pane.
The livesremain project variable tracks how many lives the frog has left. To show this value to the player, create a text box and then show the livesremain value in the text box. Follow these steps:
On the toolbar, click the Create a Text Box button and then click in the workspace to create a new text box.
This text box will be used to show how many lives remain.
Right-click (Windows) or Ctrl-click (Mac) inside the text box and select Edit from the pop-up menu.
In the Name field, enter lives to name the text box.
Don’t set the text box to transparent — text boxes that show information that changes, such as variable values, must remain opaque.
When you’re finished, click OK.
Reposition the text box in the upper-right corner of the screen.