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
.
You will need to set the colour that is sensed to the colour of your End platform.
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:
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.