Basics: Continuous Scrolling Platforms

Watch the movie
Step 1. Change the first platform
Step 2. Change the second platform

Watch the movie

If you’ve created a project with a scrolling platform, you can improve your project by making each platform scroll continuously. In other words, instead of creating many different platforms (and eventually being able to run to the end of them), you can create just two of them and then tell each platform when it moves off the screen to the left or right that it should reappear at the other side.

In the movie below, there are two platforms: a red platform and a black one. Watch how they behave as the right- and left-arrow keys are pressed.

Step 1. Change the first platform

Moving forward

When the cat moves forward and the first platform reaches the left side of the screen, we want it to leave the screen and then re-enter at the right. If we think about this slowly we can see that when the platform reaches the left side of the screen, its x position approaches -460.

To make the platform reappear at the right side of the screen we need to add the commands below to the script for the first platform.

Moving backward

When the cat moves backward and the first platform reaches the right side of the screen, we want it to leave the screen and then re-enter at the left. The logic is quite similar to what happens when the platform moves forward. The complete commands for the platform look like this. How does it work?

Step 2. Change the second platform

Make sure that the second platform’s starting x position is 470 (instead of 0).

After that, can you figure out how to make the script for the second platform?

. . .

Have fun!

Return to Games Page | Return to Home Page

4 thoughts on “Basics: Continuous Scrolling Platforms

  1. Thanks, I’m making a game in scratch as part of my IT class and this should help if i can get it to do it on its own like how temple run continuously carries on.

Leave a Reply

Your email address will not be published. Required fields are marked *