In this step, you will code your character to jump from start to end platforms.
You’re going to make your character jump across the Stage. Don’t worry about falling in yet.
Choose: Add a jumping sound that suits your character.
Now make your character jump across the Stage by pressing the space bar on a keyboard or tapping the Stage on a tablet.
Top-down jumping: See inside
This code works on a computer with a keyboard and a mobile device with a touchscreen.
Character sprite:
Test: Tap the space bar or Stage to make your character jump across the Stage to the End platform.
Adjust your code until the character jumps across the Stage in three or four jumps.
Tip: It’s really common for games to have a forever
block with if
statements inside it to do something when important conditions become true.
Debug:
Check that you have a setup script on your character sprite:
Check that that name in the go to
block matches the name of your Start sprite.
Check that you have a go to front layer
block. Your sprite might be underneath the Start plaform!
Make sure you haven’t hidden your character sprite. Add a show
block to your setup script if you need to.
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 its 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.
Add a point in direction
block to the character’s setup script or change the direction in the sprite pane. You might also need to change the rotation style
. You might also need to rotate the costume of your sprite so that it faces to the right.
Look at your character’s when I receieve (jump)
script. Try changing the number of steps in the move
blocks, or the number of repeats in the repeat
blocks.
Remember, you will need to change the numbers for the up and down parts of the jump.
Make sure you have a broadcast (start)
block at the end of your character’s when flag clicked
script.
Look at your character’s when I receieve (start)
script.
Make sure that the change size
block in the second repeat
block has a negative number to make the sprite smaller such as -3
.
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.