I am making an app similar to Jetpack Joyride, but I am having trouble creating a background that moves with the character. I’ll have to explain what I am doing for this to make sense. I have a character that constantly moves forward by adding to it’s X. I then have 2 backgrounds (same image) that just spawn next to each other. They don’t move but the character does and I have the “camera” following him so I guess technically they are moving, but they’re coordinates are stationary until I move them. When the image on the left is off the screen, it jumps to being in front. I do this by checking if the character is at an X location that is divisible by 1024. It then jumps the background image that is on the left to the right to make a continuous image.
if math.round(character.x-112)%1024 == 0 --I say -112 because he is defaulted at 112
This works until I want to speed up the character. To do so, I just change a variable that is being added to the fish’s X coordinate, but this is where I noticed the flaw in this plan. Every number I need to add to the fish must be divisible by 1024 or else it doesn’t detect it and doesn’t move the backgrounds…This means I will have to do huge jumps in his speed for it to actually work. Is there a better way to do this effect, or a simple solution to this problem? Any help is appreciated!
[import]uid: 14461 topic_id: 34296 reply_id: 334296[/import]