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?


1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 ); } } } |