How to Create a Project Variable for Lives in MicroWorld EX

By Camille McCue

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:

createprojectvar “livesremain

This command creates a new project variable with the name livesremain. The new project variable is visible on the Project pane.

image0.jpg

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:

  1. On the toolbar, click the Create a Text Box button and then click in the workspace to create a new text box.

    image1.jpg

    This text box will be used to show how many lives remain.

  2. Right-click (Windows) or Ctrl-click (Mac) inside the text box and select Edit from the pop-up menu.

  3. 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.

  4. When you’re finished, click OK.

  5. Reposition the text box in the upper-right corner of the screen.