SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

6.05 Move around your world

The player sprite should be able to walk through doors into other rooms.

Your project contains backdrops for additional rooms:

screenshot

Create a new ‘for all sprites’ variable called room to keep track of which room the player sprite is in.

  • Click on Variables in the Code tab, then click on Make a Variable.Variable blocks
  • Type in the name of your variable. You can choose whether you would like your variable to be available to all sprites, or to only this sprite. Press OK.Create variable
  • Once you have created the variable, it will be displayed on the Stage, or you can untick the variable in the Scripts tab to hide it.Variable on the stage

When the player sprite touches the orange door in the first room, the game should display the next backdrop, and the playersprite should move back to the left side of the Stage. Add this code inside the playersprite’s forever loop:

player

Every time the game starts, the room, character position, and backdrop need to be reset.

Add code to the start of your player sprite code above the forever loop, to reset everything when the flag is clicked:

Click the flag, and then move your player sprite until it touches the orange door. Does the sprite move to the next screen? Does the room variable change to 2?

×
×

Cart