Anybody Know How to Make a Wrapping background?

I’m trying to make a background which is going to wrap. Basically it is a picture of stars and I want it to make the illusion that stars are falling in the background. [import]uid: 16789 topic_id: 5145 reply_id: 305145[/import]

Look in the code exchange for joystick and download the files listed on that page. They have a scrolling background.

Its simple enough, you just create a grid of the same image and move the grid. When a grid has moved so far in 1 direction you just reset the position of the grid. As you are tiling the image the reset isnt noticeable.

http://developer.anscamobile.com/code/joystick

[import]uid: 5354 topic_id: 5145 reply_id: 17048[/import]

i downloaded the files but i’m kinda lost. can you let me know what the code looks like? [import]uid: 16789 topic_id: 5145 reply_id: 17076[/import]

have a look in tileEngine.lua, it basicaly does it for ya [import]uid: 5354 topic_id: 5145 reply_id: 17079[/import]

ok cool thanks [import]uid: 16789 topic_id: 5145 reply_id: 17082[/import]

i think i found it but i still don’t know how to make my own i’ll keep trying tho [import]uid: 16789 topic_id: 5145 reply_id: 17084[/import]

Basically its like this…

  1. You need a repeating image, in your case stars. I made the images the same as the iPhone screen 320 x 480.

  2. You tile the images and add into a group. You make the tiled group larger than the screen containing a grid of the same image.

  3. When you move the group you check to see if its moved past the boundaries you define, in my case the iphone screen edges act as the boundary.

  4. If the group has moved past a boundary you move the whole group by 1 unit back. IE if the image moves all the way off to the right x > 320 then you make x = x - 320 and as the images are repeated it gives the effect that the background is infinite.

look at

-- Reset Pattern If Moved Past Boundaries if backgroundGroup.y \> 480 then backgroundGroup.y = backgroundGroup.y - 480 end if backgroundGroup.y \< -480 then backgroundGroup.y = backgroundGroup.y + 480 end if backgroundGroup.x \> 320 then backgroundGroup.x = backgroundGroup.x - 320 end if backgroundGroup.x \< -320 then backgroundGroup.x = backgroundGroup.x + 320 end [import]uid: 18598 topic_id: 5145 reply_id: 17087[/import]

thanks lol sorry im brand new [import]uid: 16789 topic_id: 5145 reply_id: 17088[/import]

finally got some scrolling but after a few tiles it just ends, i have it set just like the sample though [import]uid: 16789 topic_id: 5145 reply_id: 17089[/import]

I think you need to look at the examples provided with joystick a bit more. Starting in main.lua follow how the tile engine is setup, how its moved and how its reset.

I cant really help more than that as you could be doing anything and I cant tell from the description.

M [import]uid: 18598 topic_id: 5145 reply_id: 17101[/import]

Maybe post your code too so we can look at it? [import]uid: 10903 topic_id: 5145 reply_id: 17168[/import]