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

2018/4/23

Lives Counter

Cmo Cmo

2018/4/23

#
need help with lives counter, trying to make it that when i hit a meteorite 1 live is taken away, until i have 0, the greenfoot stops. but for some reason it is not working.
public void checkCollision()
    {
        World world=getWorld();
        world.showText("Lives" + lives, 625,30);
        {
            if(isTouching(Meteorite.class))
            {
                world.removeObject(this);
                lives--;
                if(lives <= 0)
                {
                    Greenfoot.stop();
                    //handleGameOver();
                }
                world.addObject(newPlayer1(),400,800);

                            }
        }
    }
Cmo Cmo

2018/4/23

#
never mind, got it troops. cheers for the help, means a lot. prosper and live long
You need to login to post a reply.