PDA

View Full Version : Making a "You Win" and a "Game Over" screen dependant on score


adit2789
02-24-2008, 06:41 PM
Is there a way to make it so that if the player reaches a certain score by the end of the game, a "You Win" screen comes up, but if they fall under it is "game over". Right now the way i keep score is simply:

private function checkForHit( )
{
for (var j:Number=0; j< shootArray.length; j++)
{
for (var i:Number=0; i < bombArray.length; i++)
{
if (bombArray[i].hitTestPoint( shootArray[j].x, shootArray[j].y, true))
{

//get bomb off stage
removeChild(bombArray[i]);

//get bomb out of array
bombArray.splice(i, 1);
score ++
scoreKeep.text = String(score);
break;

}

Darunia9
02-25-2008, 07:07 PM
erm, this is sort of a guess but, wouldn't it be something like :

if (_root.score<100) {
gotoAndStop("lose_screen")
}
else if (_root.score>100) {
gotoAndStop ("win_screen")
}

not sure though x] and I haven't tested it.

been_1990
02-26-2008, 05:09 PM
var score;
if (score == 0){
_root,gotoAndStop(frame name you loose);
}
if (score == 100){
_root,gotoAndStop(frame name you Win);
}

lordofduct
02-28-2008, 04:28 AM
quickly want to point out that both those solutions would work under 2 conditions...

in been_1990 you are only checking for 2 values... what if the score is 99 or 101?

in Darunia's example he checks for all except for the score of 100.

You should use Darunias example, but make sure that one of the if statements is >= or <= to include the score of 100.