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

2016/11/1

java.lang.IllegalStateException: Actor not in world.....

Sepho Sepho

2016/11/1

#
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:711) at greenfoot.Actor.isTouching(Actor.java:972) at Zombie.stop(Zombie.java:31) at FatZombie.act(FatZombie.java:48) So if i shoot and kill one zombie i get this error My Zombie class in the act method
public void stop()
    {
        if (isTouching(Wall.class))
        {
            speed =0;
            setLocation(getX()-1,getY());
            
        }
        else 
        {
            speed=speed;
        }
        
    }
and my collision detection method
public void hitnb()
    {
      if (delay <1)
      {
      if(isTouching(NBullet.class))
        {
            removeTouching(NBullet.class);
            health = health -1;
            delay = 4;
        }  
      }
        delay--;
    }
public void dead()
    {
      if (health < 1)
      {
          getWorld().removeObject(this);
          
      }
        
    }
Pls help me thx
Super_Hippo Super_Hippo

2016/11/1

#
Show the act method.
Sepho Sepho

2016/11/1

#
public void act() 
    {
        // Add your action code here.
       
       ZombieMove();
       hitnb();
       hitsniper();
       hitshotgun();
       hitak();
       hitmg();
       hitrevolver();
       dead();
       stop();
        
    }    
Super_Hippo Super_Hippo

2016/11/1

#
Put the 'dead' method call to the very end of the act method.
Sepho Sepho

2016/11/1

#
oh i see thank you it is working now
You need to login to post a reply.