SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

3.05 Multiple games

Now you’re going to add a ‘Play’ button, so that the player can play your game lots of times.

Create a new ‘Play’ button sprite that the player needs to click to start a new game.

You can draw the sprite yourself, or edit a sprite from the library.

Picture of the play button

Add this code to your button sprite:

Button sprite

The new code includes another broadcast block, which sends the message ‘start’.

The new code makes the ‘Play’ button sprite show when player clicks on the flag. When the player clicks on the button sprite, the sprite hides and then broadcasts a message that other sprites can react to.

At the moment, the character sprite starts asking questions when the player clicks the flag. Change your game’s code so that character sprite starts asking questions when it receives the ‘start’ broadcast.

Select your character sprite and, in its code section, replace the when flag clicked block with a when I receive start block.

Character sprite

Click the green flag, and then click on the new ‘Play’ button to test whether it works. You should see that the game doesn’t start before you click on the button.

Can you see that the timer starts when the green flag is clicked, instead of when the game starts?

Timer has started

Can you change the code for the timer so that the timer starts when the player clicks on the button?

Add code to your button sprite so that the button shows again at the end of each game.

Button sprite

Test the ‘Play’ button by playing a couple of games. The button should show at the end of each game.

To test the game more quickly, you can change the value of time so that each game is only a few seconds long.

Stage

You can change how the button looks when the mouse pointer hovers over it.

Button
screenshot
×
×

Cart