i cant end my Game

time event error, im using conditional statement, it has no error but

Page 1 of 1

1 Replies - 876 Views - Last Post: 24 September 2009 - 06:00 AM

#1 123kid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 09

i cant end my Game

Posted 23 September 2009 - 09:31 PM

hi
im creating a shooting game..
and my the goal of the game is to shoot as many as you can in the time given.
and if the time runs out it should end or show a message or go to the next frame.
below is my code

stop();
Mouse.hide();
var musicGame:gameMusic = new gameMusic();
var JellyGhost_mc:JellyGhost = new JellyGhost();
var Congrats:congratsTXT = new congratsTXT();
var randomX:Number;
var randomY:Number;
var randomScaleX:Number;
var randomScaleY:Number;
var count:Number = 3;
var myTimer:Timer = new Timer(1000,count);
var scoreTxt:int = 0;
var blow:blow_mc = new blow_mc();
var testLoad:Loader = new Loader();
var fireSplat:Splat = new Splat();
musicGame.play(0,100);



myTimer.addEventListener(TimerEvent.TIMER, countdown);
function countdown(event:TimerEvent):void {
countDown.text = String((count)-myTimer.currentCount);
}
myTimer.start();
if(countDown.text == "0"){
	addChild(Congrats);
	
}



it has no error but it didnt show the Congrats image or go to the next frame. i think ive write a wrong code, any idea or alternatives?
im just a newbie here making my first game.


thanks in advance

123kid

Is This A Good Question/Topic? 0
  • +

Replies To: i cant end my Game

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: i cant end my Game

Posted 24 September 2009 - 06:00 AM

The bit of code that checks the value of your text box should be inside the function, otherwise it only checks the value once, immediately after the timer starts:
function countdown(event:TimerEvent):void {
   countDown.text = String((count)-myTimer.currentCount);
   if(countDown.text == "0"){
	  addChild(Congrats); 
   }
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1