This site requires JavaScript, please enable it in your browser!
Greenfoot back
Heet_Patel
Heet_Patel wrote ...

2018/4/24

Edge of the world

Heet_Patel Heet_Patel

2018/4/24

#
Is there a code where if an object hits the edge of the world it gets removed from the world.
nolttr21 nolttr21

2018/4/24

#
you could put this inside the act method of the object you want to remove.
if (isAtEdge())
{
    getWorld().removeObject(this);
}
Heet_Patel Heet_Patel

2018/4/24

#
okay tnx
Heet_Patel Heet_Patel

2018/4/24

#
        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 sorry
Heet_Patel Heet_Patel

2018/4/24

#
private int spawnTimer = 20;
// not important either
You need to login to post a reply.