If the car is at the edge, move 30 to left. It moves once to left and stops. I'm working from another actor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public void moveCars() { if (isAtEdge() == true ) { World world = getWorld(); List <Car> cars = world.getObjects(Car. class ); for (Car car : cars) { { car.move( 30 ); if (car.getX() == getWorld().getWidth()){ car.setLocation( 0 , getY()); } if (car.isAtEdge()== true ) { car.move(- 30 ); } } |