I'm trying to make a method where all objects of the class DarkWood should be replaced with objects of the class Stone.
All objects gets replaced but are stacked on top of each other. Some help please!
if (isTouching(Star.class)) { List<DarkWood>wood= getNeighbours(getWorld().getWidth(), true,DarkWood.class); for (DarkWood darkwood : wood) { int x = ((DarkWood) getWorld().getObjects(DarkWood.class).get(0)).getX(); int y = ((DarkWood) getWorld().getObjects(DarkWood.class).get(0)).getY(); getWorld().addObject(new Stone(), x, y); } getWorld().removeObjects(getWorld().getObjects(DarkWood.class)); }