When I play my game I always am getting this message if I hit a ship
Here is the source code for the ship
Can you help me as soon as possible?
Thanks
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.getY(Actor.java:170) at BritishShip.act(BritishShip.java:19) at greenfoot.core.Simulation.actActor(Simulation.java:583) at greenfoot.core.Simulation.runOneLoop(Simulation.java:541) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205)
public void act() { setLocation(getX(), getY()+1); checkColision(); if( getY()>=getWorld().getHeight()-0) { getWorld().removeObject(this); } } private void checkColision() { Actor a = getOneIntersectingObject(CannonBall.class); if (a != null) { Scene world = (Scene) getWorld(); world.removeObject(this); } }