Is there a code where if an object hits the edge of the world it gets removed from the world.
if (isAtEdge())
{
getWorld().removeObject(this);
} if (spawnTimer > 0) spawnTimer--;
if (spawnTimer == 0 && getWorld().getObjects(CannonballEnemy.class).size() < 5)
{
getWorld().addObject(new CannonballEnemy(), getX(), getY());
spawnTimer = 100;
}
// this is not important sorryprivate int spawnTimer = 20; // not important either