Parallax Movement Effect

Friday, February 6th, 2009 | Game Engine, Game Examples AS2

This is a fla example of my parallax engine. Can be used in top-down space shooters or side scrollers with a little work (just remove the y movement from the code).

Preview

Download Fla Sample

Download Fla Sample


Tags: , , , , , , , , ,

18 Comments to Parallax Movement Effect

John
February 7, 2009

Cool effect! Thanks.

John
February 11, 2009

unfortunately all examples are in AS2.Do you have AS3 versions of them ? Just a thought because of your site header…Flash AS2 & AS3 Game Tutorials, Samples, Source Files & Downloads.

EightySeven
February 12, 2009

The only changes I would have the images progressively get larger as they get more distant. so the img edges aren’t as visible in the furthest layer

pradvan
February 13, 2009

John, I will be releasing AS3 versions of my examples soon. I am currently trying to make a full AS2 library, and then proceed to make those examples in AS3. Unfortunately AS2 is still very popular.

pradvan
February 13, 2009

EightySeven, i added a simple “boundry” in to the example so a player wouldn’t leave the parallax field while playing around with it.

Ideally, one should stop scrolling the lower fields(maps) when they reach the edge of the stage. In the current example, the scrolling stops when the field(map) reaches the player.

Lofi
February 19, 2009

thanks for the move to AS3! looking forward to your migrated versions. your examples helped me a lot in shaping up my game :)

NoahJ
April 8, 2009

Very nice. I was a little disappointed when I saw that the star field was not dynamic, but nonetheless you did a marvelous job.
-
Great site, by the way. I will be checking it regularly.
-
- Noah

pradvan
April 13, 2009

Hi NoahJ,
It’s not dynamic to keep it as simple as possible. But I would like to make a dynamic parallax starfield effect.

When you say dynamic, do you mean just an endless starfield?

Thanks,
PR

grayhammy
April 16, 2009

Hey, this is fantastic, and works even better if you set the stage to no scale and 100%. However, if you do this, you end up running off the screen.

How would I go about making some edge detection, so that when I get to the far left, right, top or bottom, the space ship flies to the edge, instead of remaining in the middle of the screen and the starfield moving off behind it?

Thanks

Graeme

pradvan
April 16, 2009

grayhammy; modify the edge detection code to move the player if the map is next to the edge.

grayhammy
April 16, 2009

That’s exactly what I figured, I am just not entirely sure how to detect the edges.

pradvan
April 16, 2009

grayhammy; edge detection code is already in the example. That’s why the player stops when you reach the edge of the map. Look under //boundry

If you find that code confusing, try making boundries work without the parallax effect first.

grayhammy
April 16, 2009

Oh yes, my apologies. As you say though, I want to check when the map is next to the edge, not when the player is. I will have a look, thank you.

grayhammy
April 17, 2009

Pradvan, I have added a simple trace to the Key listeners to check the _x value of map_mc, as this is the main boundary MC, and this reads out fine.
-
However, if I try to use an if statement to check when the value of map_mc._x == 0 (for the left, and movieWidth for the right boundary), in order to then stop the movement of the parallax layers, and move the ship instead, it just doesn’t pick up when it hits…
-
if(path.map_mc._x == 0) {
trace(”============ HIT ===========”);
}
-
Is this because the multiplier for the movement is skipping over 0, in which case I will need to check a range around 0 or something?

pradvan
April 17, 2009

map._x is almost never going to equal to 0. That’s why you should use the < = (less than or equals to) or >= (more than or equals to) operators.

Onemorelevel
July 1, 2009

How do I get this into a new actionscript file?
I am going to make a vertical shooter, but when I open a new flash file, paste the code in there, and press control+enter, it just shows a blank screen on the preview.

pradvan
July 2, 2009

Copy everything over from the library as well.

[...] Par­al­lax Move­ment Effect [...]

Leave a comment

You must be logged in to post a comment.