A question about, scrolling platformers with parallax

mattyr64mattyr64 Member Posts: 82
edited November -1 in Working with GS (Mac)
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

  • simo103simo103 Member, PRO Posts: 1,331
    I have Darrens platform template which I don't think I would be wrong in giving advice from what I have observed in it.

    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.
  • SparkyidrSparkyidr Member Posts: 2,033
    this is how I do it in the game I am working on at the mo

    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.
  • mattyr64mattyr64 Member Posts: 82
    Thanks for the suggestions guys, I'll have a play around and see what I can come up with. I'm hoping to get 3 parallax layers working behind the main platform layer, so maybe working with the image sizes might ensure a decent framerate. Will post up how I get on.
  • mattyr64mattyr64 Member Posts: 82
    Was having a nightmare with this earlier, so decided to ditch the multiple layers of level long parallax. At the moment it looks like this > http://yfrog.com/h3pb9wp will be adding a simple layer of clouds that move still, and maybe a few other effects.
  • SquareHeartSquareHeart Member, PRO Posts: 69
    As an addition to Sparkyidr's post - here's how I figured it:

    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.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Just move the paralax layers if your actor's X linear velocity is more than, say 30 or 35. I replicate the paralax with the distance being set on the expression editor as self.size.x

    Here's the paralax I was messing around with yesterday:



    Ace
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I did paralax in this game. Basically everything is moving from the bottom to the top and consist of two images. All background images are 480 px tall, so they start at -240 and when they reach 720 (480+240), I change their positions back down to -240. Since each image will keep falling behind the other one, it looks seamless.

Sign In or Register to comment.