Hi, i've tried using isEmpty(),size()==0, size()<0...basically everything and it still doesnt work. Its about 3 hearts (lifes), when they're all gone the game should end (set new world) but it never assumes there's no more lifes. However, i've coded a method for making the last heart (size()==1) blink..and it works... so it recognizes size()==1 (and ==2, ==3 ...i've tried) but never size()==0 or isEmpty().
Thanks in advance!
CLASS LIFES()
CLASS TURTLE (if is hit, 1 life's gone)
protected void reduceLife()
{
if(isTouching(Trash.class))
{
getWorld().removeObject(getWorld().getObjects(Lifes.class).get(0));
removeTouching(Trash.class);
getWorld().removeObject(this);
}
}
Objects LIFE were created in constructor world
public void act()
{
List lifes = getWorld().getObjects(Lifes.class);
int life = lifes.size();
if(life==1)
{
switchLastHeart();
}
if(life==0)
{
VictoryNo defeat = new VictoryNo();
Greenfoot.setWorld(defeat);
}
}
