I write the following code to create an object called Zombie:
import greenfoot.*;
but I get the error:
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed.
at greenfoot.Actor.failIfNotInWorld (Actor.java: 663)
at greenfoot.Actor.getX (Actor.java: 157)
at Zombi.act (Zombi.java: 11)
at greenfoot.core.Simulation.actActor (Simulation.java: 565)
at greenfoot.core.Simulation.runOneLoop (Simulation.java: 523)
at greenfoot.core.Simulation.runContent (Simulation.java: 213)
at greenfoot.core.Simulation.run (Simulation.java: 203)
What do you think the reason for this, and how can I fix it?
public class Zombie extends Actor { public Zombie () { setImage ("zombi.png"); } public void act () { SWAT SWAT SWAT = new (); turnTowards (swat.getX (), swat.getY ()); } }