3 Lives in a game... Help please!

  • Adde
  • Beginner
  • Beginner
  • Adde
  • Posts: 47

Post 3+ Months Ago

Hi!
Was wondering if u coluld help me with a thing.. the thing is that.. if you juts could tell me how to make so after being hit by something(some enemy in a game) 3 times you will get to a game over page.. how? help please!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Keep track of deaths with a variable. Every time somthing that kills you happens increment/decrement the variable then check it,
Code: [ Select ]
function justDied(){
 livesLeft--;
 if(livesLeft > 0){
  startNewLife();
 }else{
  gameOver();
 }
}
  1. function justDied(){
  2.  livesLeft--;
  3.  if(livesLeft > 0){
  4.   startNewLife();
  5.  }else{
  6.   gameOver();
  7.  }
  8. }


startNewLife would be what you have setup to happen when you die.
gameOver would be your gameOver actions.

Somthing like this would get run when a hitTest() returns true with a baddie.
  • Adde
  • Beginner
  • Beginner
  • Adde
  • Posts: 47

Post 3+ Months Ago

What actions shall i have when i'll start a new life?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Depends on what your game does & how it's coded. The controll of lives is taken care of in this function (provided you use a _global variable for "lives") Perhaps starting a new life animation or jumping to a game over screen.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.