Game Development Reference
The only thing left to do is copy the background sprite and make a change to the script.
We'll do this using the following steps:
1. Right-click the background sprite and choose duplicate .
2. Change the staring value of x from -240 to 240 in the go to x: () y: () block. This will
cause the second background to start with its center at the right edge of the stage.
The following screenshot shows the finished script:
Objective complete - mini debriefing
As the two background images start at the opposite edges of the stage and as they are each
as big as the stage, they will each cover half of the stage area. The other half of both images
is out of view beyond the stage edges.
When both the images are acivated simultaneously with the <green lag> acion, they
will start moving, following behind each other. Both images are 480 pixels wide. The first
image will start with its center point on the left edge (x: -240), showing only the right half
of the image. The second image will start with its center point on the right edge (x: 240),
showing only the left half of the image. Their borders line up perfectly in the middle when
the program starts. Also, as they use the same scrolling speed, they will remain that way, as
if glued together. When the image disappears completely out of view, it jumps to the right
of the stage, ready to scroll in for another pass. This creates the illusion of a coninuously
Using parallax scrolling to simulate
To increase the sense of movement and depth, we are going to use a technique called
parallax scrolling . This means that objects will move at different speeds based on their
distance from the viewer. In real life, you can see this phenomenon when you are riding in
a train or a car. When looking out of the side window, you will noice that objects that are
close to the vehicle seem to be moving past a lot faster than objects that are further in the
distance. Objects on the horizon hardly seem to move at all.