A question about, scrolling platformers with parallax
![mattyr64](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hey guys, just a quick question about scrolling platformers, just after some advice really. Say I want to make a scrolling platformer, that has a level that needs to be roughly 6000 pixels long, what would be the best way to do this. I'm assuming I'd have to slice up the background image into smaller manageable pieces, but how should I go about placing them. Should I set my scene size to 6000 and just tile them down in gamesalad, or should I have a smaller scene that loads in the pieces as each is approached. I'm also wanting to have 3 layers to the background, so that I can create a parallax style sense of depth, but I'm getting a bit confused over the best way to achieve this effect. I have got parallax working, on a small 'screensized' scene, and it's fine, but for larger 'levels' I'm again a bit at a loss. This may have been covered before, so if there are any good examples I'd appreciate being pointed in the right direction. Cheers.
Comments
From what I can see he has a large scene like you plan and is using a number of images for parallax and moving them to be in camera when the hero moves about the platform. (IE they are not placed all over the scene, they are repositioned based on where the hero goes.
Hope the helps.
1. I have a 1024/1024 image. It's horizontally tile-able (but that's not important)
2. I have my platforms as non movable objects
3. Create an actor for the background image and place it in the scene, layered behind the platforms
Once you have all that, it's time to make it scroll slower than the platforms
1. Create 2 attributes in the background actor called "start.x" and "start.y"
2. Create 2 constrain behaviours as follows :
Constrain self.position.x to scene.Camera.Origin.X/3+self.start.x
Constrain self.position.y to scene.Camera.Origin.Y/3+self.start.y
MAke sure the camera is following you player actor.
You should then see the background actor scrolls around slower than the platform actors up front.
Play around with the number you are dividing by (in my example 3) to get different speeds. You can have multiple layers using this technique, but bear in mind, the constrains will eat into your frame rate.
I have the platforms, and 1 background layer, and it's pretty rock solid 60fps on a 3GS.
I have tested platforms, and 3 layers laid out in a parallax fashion, and it drops to around 58-57 most of the time.
Hope that made sense.
Make Background actor whatever size - add image - make image tilable on the Horzontal
make it non movable and make sure it is a non-scrollable layer in your scene.
create two new [real] attributes to the actor - start.X and start.Y
Create two [change attribute]s in the background actor
--- change attribute self.start.X to self.position.X
--- change attribute self.start.Y to self.position.Y
(this sets the start position of the actor into the startX/Y attribute)
Make sure you have the camera controlled by something in your scene
now add the background actor to your scene and double click it to unlock it
now add 2 more rules to the actor
---> constrain attribute self.position.X to -scene.camera /6 + self.start.X
---> constrain attribute self.position.X to -scene.camera /6 + self.start.X
this constrains the movement of the actor in the opposite direction a sixth the speed (make sure you add the minus!) If you forget the minus the background with scroll towards the direction of motion not away.
This looks great, and runs with only a 2fps framerate drop on a 3GS with 2 layers of parallax + a static background.
I hope anyone finds this useful, as parallax demo's seems pretty thin on the ground ATM.
Here's the paralax I was messing around with yesterday:
Ace
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left