what is THE best / efficient way to do a scrolling background?

part12studiospart12studios Member Posts: 620
edited June 2012 in Working with GS (Mac)
I'm making a scrolling background game for ipad. So in the past i've done it like this:

1. I have two of the same actor.. one on the screen.. and one above (scrolling down)

2. have the scrolling background leave the screen.. upon it being 100% off screen. i destroy it and spawn a new background at the top just off the screen..

This has worked ok in the past, but i have hit a problem with ipad.. when i drag a full 768x1024 graphic up top.. it gets destroyed i can only assume because the actor is outside of some arbitrary threshold GS has in place which is fine.. to get around that i just used a 1/2 sized tiling graphic thats 768x512 which is ok albeit annoying..

but yea so this approach is fine, but i thought maybe there is a better way to tile scrolling backgrounds and would love to hear other ideas.. I tried to do a constraint making the tile jump back up to the top when it hits a Y value of some amount.. but it seems like the move rule overrides it or it just misses it because of some other reason..

Because the game relies so much on the scrolling background to be efficient because it is a large graphic, anything that could avoid possible gaps in the tiling over time (which i have seen and it was painful to iron it out) i would love to hear a rock solid optimal solution

Thanks!
Caleb

Best Answer

  • MobileRocketGamesMobileRocketGames Posts: 128
    Accepted Answer
    can you clarify what you mean by:
    ..when i drag a full 768x1024 graphic up top.. it gets destroyed
    you mean in the editor? when you select the graphic from your image library and drag it to the top of the screen and let go... it gets destroyed? or do you mean if you use the change attribute behaviour to move it to the top?

    also, why are you destroying your actors?

    create a rule that says:

    ( Rule:
    Attribute Position.Y ≤ whatever value is 100% below the screen.

    Change attribute Position.Y = whatever value is 100% above the screen
    )
    This will instantly move it back to the top without it having to generate the sprite again. Saving you processing power.

    To avoid gaps in tiling you want to use images in powers of 2, that sucks i know. Also don't use timers as they are shit. Use the internal clock paired with interpolates or however you choose to make your objects move.

    As for the destroying problem, you will need to clarify.
    Hope that helps.

Answers

  • EatingMyHatEatingMyHat Member Posts: 1,246
    Why not using wrap? seems to be expensive to use Spawn and Destroy for background scroll.

  • part12studiospart12studios Member Posts: 620
    wrap? how is that used? I see wrap under graphics attributes of my actor.. all of my stuff is set to stretch.
  • part12studiospart12studios Member Posts: 620
    @rocketmobilegames hey so yea that seemed to do the trick.

    the destroy problem was my approach which was to have two graphics move together.. but using your suggested technique i only have one actor that is double the height of the stage..

    it seems that if you were to take a graphic that is 1024x1024 and put it just at the top of the screen.. it would not scroll.. instead it would vanish.. lower it a little and then the actor would not vanish..

    thanks so much for that tip. I am good at making things over complicated in GS sometimes :)

    Thanks!
    Caleb

  • MobileRocketGamesMobileRocketGames Member Posts: 128
    Hahaha yes i know i do the same! Its very easy to over-complicate things when we are so focused on a particular function or idea.
    I've found that its more efficient to make your game fit within the confines of GS than make GS work to fit the exact design of your game.
    A flexible design is invaluable.
    Good luck Part12!
  • part12studiospart12studios Member Posts: 620
    thanks so much :)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @part12studios

    Hi Caleb

    Any actor which reaches 800 pixels outside any of the screen perimeter is automatically destroyed (which you've discovered!). That's a bit of a nuisance for certain parallax-scrolling for iPad, agreed...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • part12studiospart12studios Member Posts: 620
    @gyroscope thanks for giving a specific value.. i knew it was something between 512 1024..
Sign In or Register to comment.