Advice on an unlimited scrolling background world

Hi, sorry for the long post. I am trying to implement a scrolling background, technically similar to say google maps. I don’t particularly care about it being tiled, though I assume that there would probably be a performance benefit if the world was large enough. And I want it to repeat in every direction, so you effectively never get to the edge of the world. I also need to track moving objects with respect to their location in the world and each other.

I am just looking for some advice on how to tackle the scrolling and repeating of the image/tiles.

My first attempt at this was for a small world with 1 SpriteSheet containing one image which would reflect the entire world, so the left edge would run smoothly to the right edge, and top to bottom. I then took the image from the SpriteSheet and created a 3x3 grid and added them to an ImageGroup to allow me to scroll all of the at once. This would effectively provide a world that you could scroll around 3 times before hitting the edge - aka blackness.

This all works fine, I just need to add the limitless scrolling. To accomplish this I was thinking I would check the boundary of the ImageGroup and if it was within a threshold of the screen coordinates I would increase the size of the grid by 1, so it would increase in size from 3x3 - 4x4 - 5x5 and so on. I did this just for simplicity to start with as its not very efficient since the grid size increases the further you move from the origin and never reduces.

Anyway, I couldn’t get this to work properly. Probably due to my lack of experience with the API. Can anyone tell me if I am using the API correctly? Or if anyone knows of a better way to do this, please help me out.

Thanks,
Graham [import]uid: 60857 topic_id: 32882 reply_id: 332882[/import]

Have a look at this demo -

http://developer.coronalabs.com/code/parallax-scrolling-module

Also check out all the sample apps that come with Corona.

Dave [import]uid: 117617 topic_id: 32882 reply_id: 130671[/import]

Have a look at this demo -

http://developer.coronalabs.com/code/parallax-scrolling-module

Also check out all the sample apps that come with Corona.

Dave [import]uid: 117617 topic_id: 32882 reply_id: 130671[/import]

Hi Dave, thanks for the link but that doesn’t really help me as far as I can tell. I am trying to work out how to scroll indefinitely in all directions with the background seamlessly repeating in all directions.

Anyway, I managed to get it working while chopping out all the useless code to put into an example for this topic. So thanks anyway :slight_smile: [import]uid: 60857 topic_id: 32882 reply_id: 130765[/import]

Hi Dave, thanks for the link but that doesn’t really help me as far as I can tell. I am trying to work out how to scroll indefinitely in all directions with the background seamlessly repeating in all directions.

Anyway, I managed to get it working while chopping out all the useless code to put into an example for this topic. So thanks anyway :slight_smile: [import]uid: 60857 topic_id: 32882 reply_id: 130765[/import]