public function SeedsAndPots()
{
startpage = new StartPage();
addChild(startpage);
buttonPage = new ButtonPage();
addChild(buttonPage);
buttonPage.addEventListener(MouseEvent.CLICK, GoToGame);
}
public function GoToGame(e:MouseEvent):void
{
removeChild(startpage);
buttonPage.removeEventListener(MouseEvent.CLICK, GoToGame);
removeChild(buttonPage);
gamePage = new GamePage();
addChild(gamePage);
}
//我想做一个函数,说如果时间是0,我应该去我的GameOver-Page
}
}
答案 0 :(得分:0)
创建一个倒计时变量,以秒为单位反映时间。
在您将游戏页面加载到倒计时时实例化计时器。
当时间达到0时,应用逻辑结束当前级别并在页面上显示游戏。
// store time remaining in a countdown timer
protected var countdown:uint = 60;
// create a timer, counting down every second
protected var timer:Timer;
// in your go to game, or when you want to start the timer
public function GoToGame(e:MouseEvent):void
{
// ... your go to game function
// start your countdown timer.
timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
}
protected function timerHandler(event:TimerEvent):void
{
// countdown a second
--countdown;
// update any counter time text field display here...
// if you've reached 0 seconds left
if(countdown == 0)
{
// stop the timer
timer.removeEventListener(TimerEvent.TIMER, timerHandler);
timer.reset();
// remove current gamePage
// addChild to your game over page.
}
}