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

2012/2/16

Actor not in world?

Sofalovesmusic Sofalovesmusic

2012/2/16

#
I need help please :) what am I doing wrong? when the Bubble should 'die' Greenfoot just says this: "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." and i have no idea how to fix it, but it's just really important!
    public boolean getroffen() //die Methode prüft ob der Dino die einer Bubble berührt
[code]    public boolean dead() 
    {
        Actor death=getOneIntersectingObject(Flower.class);
        return(death!=null);
    }
    public void dying()
    {
        if(dead()) 
        {
            getWorld().removeObject(this); 
        }
    }
Morran Morran

2012/2/16

#
Is "dying()" in the "act()" method? Is it the last thing in there? Or are there some things that come after it? I've noticed that if I remove my object from the world before the end of the act method, I have problems just like you're saying. Try moving "dying()" to the very end of the act method.
Sofalovesmusic Sofalovesmusic

2012/2/17

#
thank you
You need to login to post a reply.