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

2020/5/19

Another Terminal Error

Weeb3.exe Weeb3.exe

2020/5/19

#
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:713) at greenfoot.Actor.isTouching(Actor.java:978) at Bullet.IfTouching(Bullet.java:32) at Bullet.act(Bullet.java:17) at greenfoot.core.Simulation.actActor(Simulation.java:567) at greenfoot.core.Simulation.runOneLoop(Simulation.java:530) at greenfoot.core.Simulation.runContent(Simulation.java:193) at greenfoot.core.Simulation.run(Simulation.java:183)
I have no idea why it decides it wants to do this it hasn't before
public class Bullet extends Actor
{
    /**
     * Act - do whatever the Bullet wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        IfTouching();
        move(5);
    }  
    public void IfTouching()
    {
        if (isTouching(Brick.class))
        {
            getWorld().removeObject(this);
            Greenfoot.playSound("Hit.wav");
        }
        if (isAtEdge())
        {
            getWorld().removeObject(this);
            Greenfoot.playSound("Hit.wav");
        }
        if (isTouching(RobotEnemy.class))
        {
            removeTouching(RobotEnemy.class);
        }
    }
}
danpost danpost

2020/5/19

#
Switch order of lines in act method. Use "if .. else if ... else if ..." in IfTouching method.
Weeb3.exe Weeb3.exe

2020/5/19

#
ok thanks :)
You need to login to post a reply.