i when to make gameover when main actor do not have live but i have some problem at zero life..
(life<=0) it say bad operand type for binary operator...
gameover
main actor
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class gameover here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Gameover extends Actor
{
/**
* Act - do whatever the gameover wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
Button tryAgainButton;
public boolean buttonsPlaced;
public Gameover()
{
setImage(new GreenfootImage("GAME OVER", 48, Color.WHITE, Color.BLACK));
tryAgainButton=new Button();
buttonsPlaced=false;
}
public void act()
{
if(!buttonsPlaced)
{
place();
buttonsPlaced=true;
}
detectClick();
}
public void place()
{
getWorld().addObject(tryAgainButton, getWorld().getWidth()/2, 250);
tryAgainButton.setImage("Kuy.png");
}
public void detectClick()
{
if(Greenfoot.mouseClicked(tryAgainButton))
{
Greenfoot.setWorld(new Background1());
}
}
}
Life life;
public void kurang()
{
Actor Ular;
Ular = getOneObjectAtOffset(4, 4, Ular.class);
if(Ular != null)
{
Background1.getLife().life--;
if(life<=0)
{
Gameover gameover = new Gameover();
}
}
}
