Scratch Silver III
Scratch Silver II
SCRATCH SILVER I
SCRATCH GOLD III
1 of 3

5.04 Winner

In this step, you will detect the player reaching the End platform to win the game.

You’re going to add a forever loop that checks if your character is at platform level, and if so, if it has reached the End platform.

Choose: Add a winning sound to your character.

Add code to detect when your character reaches the End platform using touching color.

Character:

It’s a good idea to broadcast a ‘stop’ message to let other sprites know the game has ended. The stop other scripts in sprite block stops the loop that makes the character jump.

You will need to set the colour that is sensed to the colour of your End platform.

Some blocks in Scratch allow you to choose a colour.

You can choose a colour to match a colour that appears on the Stage.

Click on the colour input to open the colour picker and then click on the eyedropper at the bottom.

Move the mouse pointer over to the Stage and move around until you have selected the colour you want and then click (or tap) to select the colour.

The colour in the block input will change to match the colour you chose. Click in the Code area to close the colour picker.

Tip: It’s a good idea to broadcast a stop message when you detect that your game is finished so that other sprites can stop, but this sprite can do something such as playing a sound before it stops.

Test: Click the green flag and then jump your character across the Stage. Make sure you hear the winning sound when you reach the End platform.

Tip: It’s really important that you test your project before moving to the next step and adding more code. It’s harder to find and fix bugs when you have added more code.

Debug:

You need to make sure all your sprite costumes are centered in the Paint editor.

The go to (other sprite) block moves a sprite so that it’s centre is in the same position as the centre of the other sprite. If their centres are in the wrong place, then your character won’t go to the centre of the platforms.

Check that your sprite isn’t touching the End colour when it’s not on the End platform — if you use the same colour elsewhere in your project, then your character could die too soon.

Click on your character sprite and then the ‘Sounds’ tab. Make sure you have added the End sound to your sprite. Click on the Play button to make sure sound is working on your computer.

Click on the Code tab and check that the correct sound is in the play sound block that runs when the sprite reaches the End platform.

Make sure the colour is correct in the touching colour block. Select it again if you’re not sure. Sometimes colours look similar but aren’t the same.

If you have a bug that we haven’t covered here, then let us know in the feedback. If you fixed the bug yourself (well done!), let us know that too.

Tip: If you’re stuck, try reading your code out loud or in your head to make sure it says what you think it does. You might find the bug.

×
×

Cart