GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Scrollable Background on Loop

overzero3overzero3 Posts: 18Member
edited September 2012 in Working with GS (Mac)
I know there is a lot of discussions about this, but i could not find an answer in any of thoses.
I'm trying to make a scrollable background on loop in the X axis.
What i did was to put my background image (same size as my camera) on a non scrollable layer with a move behaivor to the right and set the game to Wrap X. But what happens is that the image only appear in the left side when its completely gone from the right side.
I tried duplicating the image and put them side by side so that when the first one disappears the other one is still running, but the result was akward. I dont know exaclty how to explain but in some point the image kind looks like it took too long to load and just pop after a moment of grey background area. I also tried to make the image twice as large but no good came from it.
What am I doing wrong? There is something i can do to make this transition looks seamless?

PS: Another minor question: is there a way to zoom out my workspace on GS? I'm doing a game with 720HD resolution and it kind of annoys me that I cant see the whole workspace like, say, photoshop...

Comments

  • Zoom? no, i wish! Seems odd but maybe in the new GS.

    As to your first issue, it seems you just want an animated (x-axis) background that follows the camera. Not a "scrollable" background as that would just be a regular background. There are two ways you could do this. duplicate the background image actor so that you have two. Place one directly on top of the camera, then place one directly to the right of the camera.

    So if the camera is lets say 200x150px the first background would be at a 100x75y location and the second would be at 300x75y location.
    Then place the same behaviours in both background actors:
    move: direction 180, speed whatever
    rule:
      attribute: self.position.X =< -100
    • change attribute: self.position.X = 300
    What this will do is that when the first background gets to -100 (meaning it is completely off screen to the left) it will jump to completely off screen to the right and continue moving left again. It will repeat this behaviour. Just substitute your numbers in for the ones I used.

    Now this is not technically ideal as you may get a small black line on the edge between the two background actors. This may or may not be noticeable due to the processor speed, background color and the color of the background image.

    Your other option is to create an animation of the image tiling in flash or photoshop and export it out as a png sequence. This will be very CPU intensive though and is not recommended.
  • overzero3overzero3 Posts: 18Member
    There is something very fishy happening in my GS. I created a new project to test this out and the first time only one image was "scrolling" and it did not appeard in the other side. Them, I made a new project and did all over again, and now NOTHING appears in the preview. Just a black screen of frustation! I believe the Universe is punishing me for some reason! =/
    Well, anyway, let me get this straight!
    So, I basically put two images side by side, and them add a rule that, when they get offscreen, they appear in the other side, also offscreen? Isnt that the same thing I did, only without Wrap X? Is there any advantage to this method, like performance or something?
    I sorry, but i'm starting to believe that i am doing something way wrong and i'm too stupid to realize what it is. Please, walk me throught...
    My project is in HD, so my camera is 1280x720 pixels. Thats also the size of my background image. I placed two of them, first one position is 640x360 and the second one is 1920x360. The actors logic is:
    Move Direction 180º
    When Self.Position.X =< - 640
    Change Self.Position.X to 1920
    Am i doing everything right so far? Than why it doesnt work! o.o
  • ArtBotArtBot Posts: 5Member
    "Now this is not technically ideal as you may get a small black line on the edge between the two background actors. This may or may not be noticeable due to the processor speed, background color and the color of the background image."
    My son and I are working with the same issue. And the longer the game is played, the more our thin black line gets thicker and thicker, which as you can imagine is unacceptable. I have made the background art in parts that match up perfectly and don't understand why we can't program an exact number based on a correct size. Shouldn't we be able to put in a correct (exact) number and get that to repeat seamlessly? The artwork meshes perfectly. We just need help with the code (for a horizontal looping background (on the long --960 pixel --side).
    Any help on this is appreciated
  • ArtBotArtBot Posts: 5Member
    Checking in on this, and I see no one has yet answered this question. To me it seems like a basic-game-element. A player runs (in place) and the background behind him moves in a continuous scroll-landscape-- that repeats over and over again. Can it be that this can't be set to perform correctly using Game Salad?
    This is our second game. The first didn't have a moving background, and I am not the programmer. I am making the art. Hopefully someone has the answer for us. Can a background scroll repeatedly in GameSalad (horizontally)?
    I thought there would be an easy answer to this problem.
    Thanks in advance.
  • 3xL3xL Posts: 676Member
    I had this same issue. Along with audio playing whenever it felt like it.. Can't wait for the lua drop.. Anyways...

    Turn on wrap x. Have the items move to left (or right. which ever way u desire) and it should loop automatically. Make sure items are movable and make sure that if you have some sort of gravity on, that you constrain the scrolling items y position so that it doesn't "fall" off the scene
  • overzero3overzero3 Posts: 18Member
    Yeah, you would think that this is such a basic mechanic that would work just fine even in a "simple" engine such as Game Salad, but no! Its ironic, cause the very exemple in the GS site frontpage is a 2D endless runner...a 2D endless runner that cannot be made with GS cause of some wierd glitch or whatever it is.
    Up untill now, neither wraping the background or changing position worked well enough! This is really frustating.
    If someone ever find something that work, please share with us!
  • 3xL3xL Posts: 676Member
    edited September 2012
    @overzero3
    if u want u can send me the project file and i'll take a look

    [email protected]
  • ArtBotArtBot Posts: 5Member
    overzero3 writes: "...Up untill now, neither wraping the background or changing position worked well enough! This is really frustating."

    It is more than frustrating, and it is also very surprising. This is our second game. Our first used static backgrounds and we enjoyed making it within GameSalad. Now we are evolving and need the background to loop continuously. I was under the impression (now false I guess) that the way computers work is that if one enters the correct number, the sequence would work the same way again and again. But when we scroll the background there is a vertical black line that, if anything increases overtime.

    I would imagine that there should be a set size (FOR THE BACKGROUND STRIP) that one can use to loop, based on the fact that the horizontal window is 960 pixels. Rather than send in an incorrect project to 3xL, for example, (which I appreciate the offer) I will happily modify my artwork with the size info. I will make the background strip to fit the program requirements--to whatever the correct size should be.

    We are at wits end with this. Again thanks in advance. We did write GameSalad support and they pointed us (twice) to the Forum here to find our answer. So I am looking to the community for help on this.

  • RThurmanRThurman Posts: 2,819Member, Sous Chef, PRO
    Don't move backgrounds. Instead move the camera to always point at the 'hero'.

    1) Make the scene size as long as needed (the length of all the background graphics added together).

    2) Place the background graphics in their correct sequential locations on the scene.

    3) Give the "hero" actor a control camera behavior. As the hero runs the camera will follow the actor and pan across the background graphics.

    4) When the hero reaches the end of the scene -- set its x position back to the beginning. (Set up the graphics so that the jump back to the beginning looks seamless. The last part of the right side of the background should look exactly like the beginning at the left side.)
  • 3xL3xL Posts: 676Member
    RThurman said:

    Don't move backgrounds. Instead move the camera to always point at the 'hero'.

    1) Make the scene size as long as needed (the length of all the background graphics added together).

    2) Place the background graphics in their correct sequential locations on the scene.

    3) Give the "hero" actor a control camera behavior. As the hero runs the camera will follow the actor and pan across the background graphics.

    4) When the hero reaches the end of the scene -- set its x position back to the beginning. (Set up the graphics so that the jump back to the beginning looks seamless. The last part of the right side of the background should look exactly like the beginning at the left side.)

    21908160
  • overzero3overzero3 Posts: 18Member
    Hum...that wont work for me either!
    My project is a Dual Stick Shooter, so the player will move freely in the scene. What I was trying to make was a background effect, where a fog image would move slowly in a separeted layer. This is by no means essencial to the gameplay itself, but it is a nice visual effect that make the game stand out a little bit.
    I made this fog image in Photoshop in a way that the left and right side match perfectly. The problem is match the movement in GS perfectly!
    By the way...i figured i could do a little different, and insteed of making a fixed image move, i would make a looping fog effect on After Effects and export as a sequence of PNG. The problem is, the number of pictures is way too high! How many images should i have in an animated actor? How many is the ideal not to drop performance?
    This question also apply to characters animations, such as enimies. I want my enimies to have simple animations, but dont know for sure how many frames i should use. I mean, its a dual stick shooter...expect a lot of enimies on screen at the same time!
    3xL, if you dont mind i am sending you a project with two scenes in wich i tried this background effect. If you could help me out, i couldnt be more appreciated!
  • RThurmanRThurman Posts: 2,819Member, Sous Chef, PRO
    OK -- here is an old thread that has a demo by the highly esteemed tshirtbooth. The demo is called "repeatingbg2.zip" and is 5 or six posts from the bottom.
    http://forums.gamesalad.com/discussion/40282/scrolling-background-not-using-scene-wrapping-please-help
  • ArtBotArtBot Posts: 5Member
    "tshirtbooth SOUS CHEF, LINE COOK February 28
    have you thought about making the scene the color of your BG and then just adding in all the other stuff with a transparent BG so you can't tell if there is ever a gap?
    Email = [email protected] ----- Skype = Tshirtbooth"
    killerpenguins MEMBER February 28
    I had it run for about 30 min on my iPod and it was going at 60 FPS and it started to space apart. I did think about that and tried it but because the level of detail and shades my background is, you are able to tell when it gaps apart. This is a pain in the behind! LOL Again, thanks!"
    So, wow I am quoting that thread to here now and the final post in that thread still states that Tshirtbooth's code isn't working. Am I to conclude that GameSalad can't successfully scroll a seamless background? WIth all the GameSalad development out there, and the participants on this forum, isn't there a working solution?
    I am using this post as a final plea for a solution to this problem.
    Help glub, glub we are drowning if we can't get a life saver here.
  • mELTINGsKYsTUDIOSmELTINGsKYsTUDIOS Posts: 158Member
    Hey there, I can whip you up a quick demo.. But I dont know how to embed it in the forum.. Its quite easy! What is the size of the scene you are using?
  • uptimistikuptimistik VenezuelaPosts: 3,602Member, Sous Chef, PRO
    give this a try and let me know if it will work for u..

    New Templates Daily At The Official GameSalad Marketplace GSHelper.com

  • ArtBotArtBot Posts: 5Member
    Thank you. I like the title (as I am looking for the perfect scroll after all!). Will try it tonight and let you know then.
    Much appreciated!
  • mELTINGsKYsTUDIOSmELTINGsKYsTUDIOS Posts: 158Member
    @uptimistik how did you embed the file like that.. Ive been trying to figure that out for a while. haha
  • uptimistikuptimistik VenezuelaPosts: 3,602Member, Sous Chef, PRO
    Oh, I think only the Line Cooks and Sous Chefs can do that. You can try this though:
    1.) Create a DropBox Account http://db.tt/He1kDL8u
    2) Upload your stuff to DropBox, right click on it and choose Copy Public Link
    3) Paste it here for everyone to enjoy :)

    New Templates Daily At The Official GameSalad Marketplace GSHelper.com

  • mELTINGsKYsTUDIOSmELTINGsKYsTUDIOS Posts: 158Member
    @uptimistik Thank you sir! Ive been scratching my head on that one for a week or so!
  • mELTINGsKYsTUDIOSmELTINGsKYsTUDIOS Posts: 158Member
    edited October 2012
    Here is how I normally do it. uptimistiks way may be better tho.. Ive always had it work out well using this method as long as I line it up right. Dont mind the graphics, I just whipped them up to throw in there haha..

    https://www.dropbox.com/s/6lyessyxc1ai3r9/scrolling background.zip
  • uptimistikuptimistik VenezuelaPosts: 3,602Member, Sous Chef, PRO
    @mELTINGsKYsTUDIOS that is of course the perfect solution :) but! we're trying to avoid a Scene Wrap because it affects all the actors in the Scene.

    New Templates Daily At The Official GameSalad Marketplace GSHelper.com

  • mELTINGsKYsTUDIOSmELTINGsKYsTUDIOS Posts: 158Member

    @mELTINGsKYsTUDIOS that is of course the perfect solution :) but! we're trying to avoid a Scene Wrap because it affects all the actors in the Scene.

    But with the extended scene that I added and a few placed walls should make it function right? Or am I misunderstanding the game play element?
  • uptimistikuptimistik VenezuelaPosts: 3,602Member, Sous Chef, PRO
    unfortunately, lots of games can't use either Scene Wrap or Scene Gravity as you've got it set up.

    New Templates Daily At The Official GameSalad Marketplace GSHelper.com

  • famekraftsfamekrafts Posts: 829Member, BASIC

    give this a try and let me know if it will work for u..

    Its not working for the ipad resolution of 1024 x 768

    what coordinates should I use for that?

  • famekraftsfamekrafts Posts: 829Member, BASIC
    Bump

    friends any help here. I am stuck badly with the background.
  • overzero3overzero3 Posts: 18Member
    Woah! This thread grew while i was away!
    Well, just downloaded uptimistik solution and it looks pretty much the same thing i was doing, just using interpolate insteed of change attribute! Still worth the try!
    I sent an project with my solution (which used change attribute) to 3xL and he said that the problem could be that the image was too big! Using dividing the image into smaller ones could help! I still did not had time to test it (i did not had time to anything, lately) but when i do i'll say what worked best!
    But overall, it's still wierd that such a simple mechanic is giving so much trouble!
  • famekraftsfamekrafts Posts: 829Member, BASIC
    overzero3 said:

    Woah! This thread grew while i was away!
    Well, just downloaded uptimistik solution and it looks pretty much the same thing i was doing, just using interpolate insteed of change attribute! Still worth the try!
    I sent an project with my solution (which used change attribute) to 3xL and he said that the problem could be that the image was too big! Using dividing the image into smaller ones could help! I still did not had time to test it (i did not had time to anything, lately) but when i do i'll say what worked best!
    But overall, it's still wierd that such a simple mechanic is giving so much trouble!

    I think the problem is because of the ipad resolution anything offscreen (more than 1200 x gets auto destroyed, so maybe using a wide screen resolution say 2048 x 768 might help.

    I am giving this a try.
This discussion has been closed.