|How can I make a moving background?|
There are several ways to make a background move while an animated character stays in one place, so that the character appears to be moving past scenery.
Method 1: Create several backgrounds which transition smoothly from one to the next. Copy and paste them into shapes. The shapes may be as wide and as high as the project pages, or they may be narrower. Hatch and position three or more turtles to wear these shapes. Set the turtles' headings so that they will move to the right or left, as you wish. Hatch another turtle to become the animated character. Be sure to hatch that turtle last so that it will be in front of the others, or else use the infront command (MW Pro).
The first sample project below uses 3 wide shapes with several buildings on each shape. Note: As the midpoint of a shape moves off the edge of the project, it "jumps" to reappear at the opposite edge of the project. Wider shapes produce a jerkier background animation. The speed slider controls the speed of the moving background turtles. The animated character turtle has been named walker.
See How do I move the turtle? for extra information.
Method 2: Save background pictures as separate graphics files and then load one picture after another as the character moves.
To save a background as a picture file (in this case a GIF file), type in the command center:
and hit Enter. The background will be saved as a separate file in the same folder as the project.
Be sure that the whole scene has been drawn or stamped on the background, for the savepict command saves only background pictures, not objects such as turtles.
Method 3: Create background pieces (such as individual buildings or trees) and place them into shapes. Hatch turtles and place some of the background shapes on these turtles. Set the turtles' headings so that they will move in the direction you wish.
The procedures below demonstrate how the turtles can change their shapes at random when they reach the edge of the project. In this way the background scenery appears to be quite varied as it glides along.
(Note: The set command at the beginning of the city and woods procedures simply deactivates the other button so that both procedures cannot be running at the same time.)