When "Canguru" hit the "Peixe", greenfoot stop and give-me
java.lang.NullPointerException
at Canguru.act(Canguru.java:22)
SOMEONE CAN HELP-ME PLEASE
public class Canguru extends Actor { public void act() { move(3); if(Greenfoot.isKeyDown("left")){ turn(-2); }else if (Greenfoot.isKeyDown("right")){ turn(2); } if(isTouching(Peixe.class)){ getWorldOfType(MyWorld.class).getGato().setLocation( Greenfoot.getRandomNumber(300),Greenfoot.getRandomNumber(300)); } } }
public class Peixe extends Actor { /** * Act - do whatever the Peixe wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(3); if(Greenfoot.getRandomNumber(10)>=5){ turn(Greenfoot.getRandomNumber(90)-45); } } }