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

2022/1/30

cant get the zombie boss lives to go down

Soop__ Soop__

2022/1/30

#
this is the zombie boss code for being hit by a bullet:
    public void hit()
    {
        Actor Bullet = getOneIntersectingObject(Bullet.class);
        if(Bullet != null)
        {
            waveZWorld waveWorld = (waveZWorld)getWorld();
            waveWorld.ZombieBossLife();
            waveWorld.removeObject(Bullet);
            waveWorld.increaseScore();
        }
    }
and this is the world fucntion for the zombie boss life system:
    private int zombieBossLives = 3;
    ZombieBoss zombieBoss;
    public void ZombieBossLife()
    {
        zombieBossLives = zombieBossLives - 1;
        if(zombieBossLives <= 0)
        {
            removeObject(zombieBoss);
        }
    }
it doesn't remove the zombie boss at all and i dont know why. can someone help find the problem, thanks.
danpost danpost

2022/1/30

#
Soop__ wrote...
t doesn't remove the zombie boss at all and i dont know why. can someone help find the problem, thanks.
What all codes do you have in your world for the zombieBoss field? (specifically in your prepare method or world constructor)
Soop__ Soop__

2022/1/30

#
hi danpost finally got it working thanks for the help :)
You need to login to post a reply.