I'm currently working on a game in which all of the elements are 'loopable'. When they move out of the screen on the right they get back in on the left and visa versa. I now just check when a object gets out of the screen bounds and change the x position accordingly. The thing is that this is visually not so appealing. So the next logical step I want to take (which I'm currently stuck at) is that these elements are already visible on the left when they're moving out of the screen on the right. The following image makes it a little bit more clear.. Hopefully..
How it's working:
- I draw all of the elements sprites in a SpriteBatchNode
- There can be more than 100 sprites in a SpriteBatchNode
- The elements in this case don't have any collision
- I cannot make a duplicate of the elements and draw them because this would simply be to heavy.
What i'm thinking.
1. I'm thinking of subclassing SpriteBatchNode and TextureAtlas. TextureAtlas holds all the quads. If a quad is partly out of screen boundary than add an extra quad for this sprite on the opposite.
2. Draw the SpriteBatchNode normally but in the visit() method set the position of the SpriteBatchNode minus the screen width and draw this into a RenderTexture. After this set the position back. This method sounds pretty easy. But the thing is I just can't get the BatchNode to be drawn in the RenderTexture properly..
Hopefully someone can help me out here!! .. Really stuck <-<- Said faces... <--- even more..
LoopingExplained.png (27.3 KB)