I need help in ActionScript3.0

徘徊边缘 提交于 2020-01-17 02:20:08

问题


I am working on a time limit game, but when I load the game and it passes the time limit that is placed it reaches zero but it is not directed to the next scene where I have the game over .. this is the code that is placed

var tiempo:int;
var Duracion:int;


Duracion = 7;
tiempo = Duracion;
var timer:Timer = new Timer(1000,Duracion);
timer.addEventListener(TimerEvent.TIMER, tiempo2);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, fin)
timer.start();


function tiempo2(tiempoevent:TimerEvent):void
{
    trace(tiempo);

    tiempo--;

    time.text = tiempo.toString();

}

function fin(tiempoevent:TimerEvent):void
{
    var timer:Timer = tiempoevent.target as Timer;
    timer.removeEventListener(TimerEvent.TIMER, tiempo2)
    timer.removeEventListener(TimerEvent.TIMER, fin)


}

How do I get you to the game over scene ... I'm working on animate cc


回答1:


This should work

 function fin(tiempoevent:TimerEvent):void
 {
     var timer:Timer = tiempoevent.target as Timer;
     timer.removeEventListener(TimerEvent.TIMER, tiempo2);
     timer.removeEventListener(TimerEvent.TIMER, fin);
     nextFrame();
 }


来源:https://stackoverflow.com/questions/41201497/i-need-help-in-actionscript3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!