Got a question about my boot actor. It has 3 hearts, but greenfoot continues after all hearts are depleted. What am i doing wrong this time.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class boot here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class boot extends Actor
{
/**
* Act - do whatever the boot wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.isKeyDown("left"))
{
move(-3);
}
if (Greenfoot.isKeyDown("right"))
{
move(3);
}
if (Greenfoot.isKeyDown("up"))
{
setRotation(90);
move(-3);
setRotation(0);
}
if (Greenfoot.isKeyDown("down"))
{
setRotation(-90);
move(-3);
setRotation(0);
}
}
private void hit()
{
Actor barrel;
barrel = getOneObjectAtOffset(0, 0,barrel.class);
if (barrel != null)
{
World world;
world = getWorld();
world.removeObject(barrel);
}
}
public boot()
{
GreenfootImage image = getImage();
image.scale(230, 130);
setImage(image);
}
public void removeLive()
{
int lives = getWorld().getObjects(heart.class).size();
getWorld().removeObject((Actor)getWorld().getObjects(heart.class).get(lives-1));
if (lives != 1)
{
//
}
else
{
Greenfoot.stop();
}
}
}
