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

2014/8/8

How to do a health bar or a 3 life

Al7amed Al7amed

2014/8/8

#
What I mean is in each level you have 3 life. for example if you in level four and you die for the first or second or third time you repeat the same level four but from beginning but if you die for the fourth time you will go back to the level one or the main menu
NikZ NikZ

2014/8/8

#
Just have an int, like int lives = 3. Then every time you die, then lives--. If lives is 0, than go back to level 1 or MM.
Al7amed Al7amed

2014/8/8

#
can you write the code please .. I'm not a good enough in greenfoot thank you
danpost danpost

2014/8/8

#
Sounds like you need my Super Level Support Class. It has what you need for level changing.
NikZ NikZ

2014/8/8

#
private int lives = 3;
die()
{
  lives--;
  if (lives == 0) {
    //do the stuff , like level 1 or MM
  }
}
You need to login to post a reply.