Scrolling Background (Wrap...)

ZillaZilla Member Posts: 157
edited November -1 in Working with GS (Mac)
How do I create a background that is scrolling infinitely from left to right similar to this example (that you cannot download unfortunately...)?

http://gamesalad.com/game/play/33976

Comments

  • ZillaZilla Member Posts: 157
    Besides: How do I use the Actor Attributes "Horizontal Wrap" and "Vertical Wrap"?

    Unfortunately, these attributes are not explained in the Wiki:
    http://gamesalad.com/wiki/interface_reference:actor_attributes
  • ZillaZilla Member Posts: 157
    Hi, tshirt

    I didn't mean the check boxes in the SCENE attributes, I meant the "Horizontal Wrap" and "Vertical Wrap" drop down list boxes in the ACTOR attributes (Graphics section).
  • sdparduesdpardue Member Posts: 110
    Zilla,

    I didn't know how to use those Actor Attributes either, so I just did a little experimenting.

    They control how a graphic fills the Actor. For example, if you set both to "Tile", and the graphic for your actor is 20px by 20px, and you set the size of the Actor to 200px by 200px, the Actor in your scene will display a 10x10 tiled array of the graphic. Set both attributes to Stretch, and you'll see the 20px by 20px graphic stretched to 200px by 200px. Normal keeps the graphic its original size.

    As per your question about the infinite background scrolling, a simple way is to place a 480px wide graphic in the scene, give it a move 180 behavior, and set the scene Wrap X attribute. With several graphics representing different layers of the background, moving at slower speeds as they represent objects further away, you can achieve such an effect. And of course you need to use the Layout Menu options to arrange the graphics. There's a lot of attention to detail, as in JCFord's example, that can make it more realistic.

    And if I'm not mistaken, that example uses graphics that are wider than 480px. You can't (that I'm aware of) use the scene Wrap X with graphics wider than the 480px, the screen width. You must turn Wrap X off. In that case, you can use two copies of the 480px graphic, side by side, both moving the same direction at the same speed. When one leaves the screen (its x value = -240) i set it to the x value of its neighbor + 480, effectively placing it on the right side, ready to come into view. You'll need to constrain some game attributes (variables) you create, so you'll have access to these values.

    Of course all of these methods require that you create graphics that can tile or connect the left and right edges of your graphic. There are Photoshop plug-ins that can do such, but I'm not familiar enough with any of them to recommend one over another. That's better handled by someone with more knowledge and experience in that area.

    Hope this helps.
  • ZillaZilla Member Posts: 157
    @sdpardue: Thank you for this info about the Actor Attributes :)

    I was also experimenting with the SCENE wrap attributes and they work great if ALL your actors should wrap. But I just want to wrap the background.

    The method that you mention is also described by CodeMonkey:
    http://gamesalad.com/forums/topic.php?id=85#post-345

    I made a small example of this:
    http://gamesalad.com/game/play/43885

    As you can see, it works o.k. theoretically, but there is small horizontal line where the two tiles should connect...
  • sdparduesdpardue Member Posts: 110
    Try backing off one or more pixels when you reset the Y value. For example instead of 320, try 319 or 318. This might be related to the speed of movement... not sure.
  • rebumprebump Member Posts: 1,058
    Others have gotten rid of the "horizontal" (don't you mean vertical?) line by making their scrolling pieces a bit larger than the window width and then having the scrolling pieces that are side-by-side overlap a few pixels.
  • ZillaZilla Member Posts: 157
    @rebump & sdpardue:
    I will try your suggestions :)
Sign In or Register to comment.