Suggestions for endless, scrolling tile background?

I have a small 32x32 tile I would like to use as an endlessly scrolling background. It’s a seamless tile for grass, and I want it to look like the ground is constantly moving (the player is running).

This is my current solution.

First, in my initialization function:

[lua]local id = 0

for row = 0, display.contentHeight+128, 32 do

for col = 0, display.contentWidth, 32 do
background[id] = display.newImage(“tile-grass.png”)
background[id].x = col
background[id].y = row
id = id + 1
end

end

backgroundTilesTotal = id[/lua]

then, in my game loop:

[lua]for id = 0, backgroundTilesTotal, 1 do
local newY = background[id].y + cameraY
if newY > display.contentHeight + 64 then
newY = newY - display.contentHeight - 128
end
background[id].y = newY
end[/lua]

This basically keeps shifting all of the tiles down (cameraY is basically the speed), which makes it look like the background is moving.

I have a feeling this is eating up a decent amount of performance, and there are also occasional “seams” that show up between the tiles.

I tried searching the forums, and google for alternate solutions, but came up short. Anyone have a better solution, or a suggestion on how to do this differently? Would using larger tiles (say, 128x128 instead of 32x32) be better for performance? [import]uid: 49447 topic_id: 15896 reply_id: 315896[/import]

Filling pixels on the screen is hardware-accelerated (done by the GPU), moving separate object coördinates before handing them over to the GPU is done by the main processor. So, in short: if you have the choice, move fewer bigger objects around instead of more smaller ones.

In your case it sounds as if two tiles might even be enough! [import]uid: 70134 topic_id: 15896 reply_id: 58823[/import]

thanks, 2 tiles may indeed be enough. However I may need to rethink me original plan of creating a tile-based background for a semi-designed level. Or at least greatly increase the size of my tiles. [import]uid: 49447 topic_id: 15896 reply_id: 58850[/import]