Hi I have got a problem with my code because I need to make a simple method that checks if an object is in world.
code for bear.class
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class bear here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class bear extends Actor
{
/**
* Act - do whatever the bear wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int range = 0;
public void act()
{
if//object is in world. code needed here.
{
poorpig pig = (poorpig)getWorld().getObjects(poorpig.class).get(0);
getWorld().getObjects(poorpig.class).get(0);
}
}
}