Basically, I want to create some sort of limit that limits the creation of an object. Here, it's bomberMoveSpot. It works in the sense that it spawns the moveSpot, but it's not limiting the number moveSpots. The limit is supposed to be limited by spawnLimitMoveSpot, but I think it's not even being used in the correct way.
Here is my code so far:
I think
and
are redundent, I think.
Actor moveSpot = getOneObjectAtOffset(0, 0, bomberMoveSpot.class);
boolean hasHitSpot = isTouching(bomberMoveSpot.class);
int spawnLimitMoveSpot = 1;
if (this != null && moveSpot != null )
{
getWorld().removeObject(moveSpot);
spawnLimitMoveSpot = spawnLimitMoveSpot - 1;
}
if (spawnLimitMoveSpot == 1)
{
getWorld().addObject(new bomberMoveSpot(), Greenfoot.getRandomNumber(320), getY());
}
else
{
getWorld().removeObject(moveSpot);
}
return hasHitSpot;Actor moveSpot = getOneObjectAtOffset(0, 0, bomberMoveSpot.class);
boolean hasHitSpot = isTouching(bomberMoveSpot.class);
