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

2019/4/3

How do i fix this?

t.jongsma t.jongsma

2019/4/3

#
public class Explosie extends Actor
{
    private int timer = 5;
    /**
     * Act - do whatever the Explosie wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        getImage () .scale(60,60); 
        ballonWegNaExplosie();
        muurWeg();
        eindeSpel();
    }    
    public void eindeSpel()
    {
        

    }
    
    
   public void muurWeg()
    {
       removeTouching(Muur.class);
         
        
        
    }
    public void ballonWegNaExplosie()
    {
        if(timer > 0)
            timer--;
        else
        {
            getWorld().removeObject(this);
             
            

            

        }
    }
}
t.jongsma t.jongsma

2019/4/3

#
The explosion (ballonWegNaExplosie) doesn't work, it gives me this "java.lang.IllegalStateException: Actor not in world" warning. this code is for my bomberman game.
Super_Hippo Super_Hippo

2019/4/3

#
Try to swap lines 11 and 12. And move line 10 into the constructor. No need to execute it every act cycle:
public Explosie()
{
    getImage().scale(60, 60); 
}
You need to login to post a reply.