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

2019/12/17

NEED HELP! How to fix Actor not in World error?

KAA KAA

2019/12/17

#
if (Greenfoot.mouseClicked(null))
        {
            MouseInfo r=Greenfoot.getMouseInfo();
            if (r!=null)
            {int d=(int)(Math.sqrt(Math.pow(r.getX()-v1.getX(),2)+Math.pow(r.getY()-v1.getY(),2)));
            System.out.println(d);
            if (Greenfoot.mouseClicked(v1))
            {
            mu.setVolume(100);
            mu.play();
            removeObject(v1);
            vacaw v2=new vacaw();
            addObject(v2,200,250);
            showText("Encontraste a la vaca invisible",200,320);
            showText("Tiempo:"+reloj.current()+"segundos",200,350);
            Greenfoot.stop();
            return;
            }
        
            if (d>=300)
            {
               mu.setVolume(10);
               mu.play();
               return;
            }
            if (d<300 & d>250)
            {
                mu.setVolume(20);
                mu.play();
                return;
            }
            if (d<=250 & d>200)
            {
                mu.setVolume(30);
                mu.play();
                return;
            }
            if (d<=200 & d>150)
            {
                mu.setVolume(40);
                mu.play();
                return;
            }
            if (d<=150 & d>100)
            {
                mu.setVolume(50);
                mu.play();
                return;
            }
            if (d<=100 & d>75)
            {
                mu.setVolume(60);
                mu.play();
                return;
            }
            if (d<=75 & d>50)
            {
                mu.setVolume(85);
                mu.play();
                return;
            }
            if (d<=50)
            {
                mu.setVolume(90);
                mu.play();
                return;
            }
        }
It gave me this 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. the error appears in the vacaw v2=new vacaw(); line (its always in the same line no matter how i move the code tho) this code goes in the act of world. You click anywhere and depending on the distance within the object (int this case v1) and the place you give a click, it plays the same sound in a different volume (louder if closer) and if its a click on the object the game ends, or at least thats whats supposed to do... Sorry for my bad English @-@, please help, its urgent :(((
KAA KAA

2019/12/17

#
can i get uh... one reply.....?
danpost danpost

2019/12/17

#
KAA wrote...
the error appears in the vacaw v2=new vacaw(); line
Please show your vacaw constructor code (it is in the vacaw class and starts with 'public vacaw()'.
You need to login to post a reply.