This site requires JavaScript, please enable it in your browser!
Greenfoot back
jrod159
jrod159 wrote ...

2016/12/7

weird error need help

jrod159 jrod159

2016/12/7

#
so i have 2 bullet classes 1 bullet class for the enemys and one class for the hero and i have barriers when either bullet class hits the barrier the bullet and the barrier and they have the same code but im getting an error under one this is my code right now
public void act() 
    {

        Actor Bullet = getOneObjectAtOffset(0, 0, Bullet.class); //this code removes the bunker and the bullet when they make contact
        if (Bullet != null){ 
            getWorld().removeObject(Bullet);
            getWorld().removeObject(this);
            Cruiser.istoast = false;
            

        }
        Actor Marinebullet = getOneObjectAtOffset(1, 1, Marinebullet.class); //this code removes the bunker and the bullet when they make contact
        if (Marinebullet != null) { 
            
            getWorld().removeObject(Marinebullet);
            getWorld().removeObject(this);
            
            

        }
    }
}

and the error says (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.) so the game stops when the bullet hits the barrier but it is fine when the Marinebullet hits the barrier i need help please
Nosson1459 Nosson1459

2016/12/7

#
What code is this for (show more)? This is the place the error is (which line)?
danpost danpost

2016/12/7

#
Place the following line at 9 an 17:
return;
jrod159 jrod159

2016/12/7

#
thank you! it works now :)
You need to login to post a reply.