Hello, I am trying to make it so that when all of the enemies in a world are gone, it adds an object to that world. My issue is that after all of the enemies have been killed, it adds the object hundreds of times and will in turn lag out the game. I need to know how to make it add only one object. Here is my code:
public void allowAccess()
{
if (getObjects(Enemy.class).isEmpty())
{
GatewayTwo gatewaytwo = new GatewayTwo();
addObject(new GatewayTwo(), 1277, 541);
}
}

