Hello again, i got a problem with a moving object in my shooting game development. the problem is whenever i move (with keypress) my actors and press the shoot button both at the same time, the game keeps crashing and give this notif 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:681)
at greenfoot.Actor.getX(Actor.java:157)
at AimDisplay.move(AimDisplay.java:147)
at AimDisplay.act(AimDisplay.java:94)
at greenfoot.core.Simulation.actActor(Simulation.java:594)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
i used this basic code:
public void move()
{
int speed = 1;
{
if(Greenfoot.isKeyDown("left"))
setLocation(getX() - speed, getY());
if(Greenfoot.isKeyDown("right"))
setLocation(getX() + speed, getY());
}
}
