I need help with looping objects

Im trying to loop planets in the background, i already have them slowly levitating from right to left, i just need help with how i can get them to show up on the right side of the screen after dissapearing again and again. Is it a loop or is it spawning the objects repeteadly?

Add all your planets to a Group
then just check
if GroupOfPlanets.X() > screenWidht() + GroupOfPlanets.With()
//Do something like set GroupOfPlanets.X() = -screenWidth()

1 Like

Im not sure it worked. Wouldnt that just change the size of the planets? Here is the code in case i did something wrong.
Thanks for your help anyways!

Why are you messing with the object width? @UlisesFreitas said to change the X position, not the width.
Assuming the planets have their origin at the top left of the sprite, use the following:

1 Like