How can I make a cycle where a character actor walks over a ground actor and when that ground actor disappears from the screen it is generated again after another ground actor?
import greenfoot.*;
public class Ground extends Actor
{
public void act() {
int worldWidth = getWorld().getWidth();
if (getX() < worldWidth/2) {
move(worldWidth*2);
}
if (getX() >= worldWidth*3/2) {
move(-worldWidth*2);
}
}
}