I have one image: background.png. How to create continuously repeating scrolling background image with android OpenGL ES or AndEngine library or other technology you know?
Example:
Currently, I use two-adjacent-image technique. I load image (background.png) two times and I put them adjacently, then I move them. So it looks like just one image scrolling continuously.
But, somehow I think there might be a better solution with just using one image instance. Anyone can share?
UPDATE:
For the one who curious, this is the two-adjacent-image code (using AndEngine library):
movingBackgroundSprite.registerEntityModifier(new LoopEntityModifier(
new MoveYModifier(10, -CAMERA_HEIGHT, 0)));
movingBackgroundSprite2.registerEntityModifier(new LoopEntityModifier(
new MoveYModifier(10, 0, CAMERA_HEIGHT)));
Above code is about making a background image repeatedly & vertically scrolling from top to bottom.
Note:
* movingBackgroundSprite is a Sprite class that load the background.png image. You can see there are two instances of the background Sprite.
* registerEntityModifier -> apply modifier/behaviour for the Sprite
* LoopEntityModifier -> looping behaviour
* MoveYModifier -> moving behaviour by y-position. The 1st argument is the duration (you can ignore this since it's nothing to do with the question), the 2nd argument is the Source-Y position, the 3rd argument is the Destination-Y position.
* CAMERA_HEIGHT -> constant that define the height of background image.