Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories Building Games in Flash 5 - Part 2 - Scrolling
Author: David Doull | Website: http://www.artifactinteractive.com.au |

 
Page 3
«prev 1 2 3 4 5 6 7 next»

Step 2: Let's get the ground scrolling.

The ground will scroll to the left of the screen, which is achieved by gradually reducing the x-coordinate of the ground movie clip.

We actually need two copies of the ground movie clip placed next to each other to achieve a smooth scrolling effect. The second copy is sometimes referred to as a buffer. This ensures that the ground always covers the stage. There is a little flash file below that demonstrates this:


press the play button to see it in action.

 


When the first copy of the ground has moved completely off the left of the stage both copies of the ground are reset back to their start positions.

Duplicate the ground

As shown above, we will need a second copy of the ground movieclip.
Which means we are going to duplicate the ground movie clip. So we will have two copies of the ground movie clip next to each other.

Instead of moving both of these movie clips to create our scrolling, what we will do is put them inside another movie clip (which we will call mainGround) and then we can move this parent movie clip instead of the two ground movie clips. In other words the mainGround movie clip will contain the two copies of the ground and we will just move mainGround instead of moving the two grounds individually.

The first thing we need to is to put the ground movie clip inside another new movie clip.

Select the ground movie clip and create a new movie clip (Insert> Convert to Symbol or F8). Give it the name mainGround and choose movie clip as the behaviour. Then in the instance panel set the instance name of this new movie clip to mainGround (as shown).

So what we now have is the ground movieclip inside of the mainGround movie clip. Why did we do that? Because we will now duplicate the ground movie clip within the mainGround movie clip. Then we will be able to move the two ground movie clips at once by just moving the parent mainGround movie clip. This will be less work for the flash player - as it only has to move one movie clip not two and hence will improve the speed of the scrolling. It seems like extra work for little pay off - but in building flash games the speed of the flash player is very important, so where-ever possible you should reduce the amount of code or movie clip manipulation that flash has to do.

We are now going to add in the clipEvent code for the mainGround movie clip. Select the mainGround movie clip and choose Window> Actions to open up the actions window then type the following.

Type the following code in the actions window.

onClipEvent (load) {
 ground.duplicateMovieClip("ground2", 100);
 ground2._x = ground._x+ground._width;
 groundStartx = this._x;
 groundSpeed=10;
}

This code is contained within a load ClipEvent, so it will be run when the mainGround is first loaded.

The second line of the code makes a duplicate copy of the ground movie clip and gives it the name ground2 and a depth of 100.
The third line sets the x-position of ground2 to the x-position of the original ground plus the width of the ground. This has the effect of locating ground2 exactly to the right of the first ground movie clip.

The fourth line creates a new variable called groundStartx which is equal to the x-position of the the mainGround movie clip. The purpose of this variable is to store the start location of the mainGround movie clip - we will use this variable later.

The fifth line groundSpeed=10; just sets up a new variable called groundSpeed with a fixed value of 10. This will be the number of pixels the ground moves per frame.

 

«prev 1 2 3 4 5 6 7 next»

» Level Intermediate

Added: : 2001-05-01
Rating: 8.57 Votes: 232
Hits: 6861
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (100 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments