1

Im making a 2d game and I want enemies go right to the left and when one enemy goes out of the screen (on the left), instantly appears at the beggining again (on the right). How can I do this?

I can do the movement with addAction without a problem, but I have no idea about the "respawn" thing.

MarcusF
  • 43
  • 7

1 Answers1

2

It's a bit hard to help you without any code example from your game. Assuming that you have something in your action that alters the position like

x = x - pixelPerSecond * deltaTime;

then why not just adding some condition like

if (x <= treshold) {
  x = startX;
} else {  
  x = x - pixelPerSecond * deltaTime;
}

Edit: Just edited "+" to "-" because you said "from right to left". But idea is the same.

Sebastian
  • 5,721
  • 3
  • 43
  • 69