简体   繁体   中英

AS3 how to go to next frame in MainTimeline when character die animation ends

so I need to know if my character(bird) hitTestObject with pipe he plays the die animation after the animation ends it need to go to the game over frame in the main timeline

if (bird.hitTestObject(pipe1)) {

 bird.gotoAndStop(3); //frame 3 = where the die animation is 

}

LINK 1 (here you see different frames for animations frame 3 is die animation) http://gyazo.com/67381832827bfb8a4dac2452076a4217

LINK 2 (the die animation) http://gyazo.com/bf5153a9d00e1478471fff7b73d0c592

so here you can see the animation in the end of the animation there need code to go to game over frame in the main timeline frame 3

btw its not in a .as file but in the timeline

thank you if you can help me and if my english is not good sorry about that im dutch

Try using an enter frame event, like so:

if (bird.hitTestObject(pipe1)) {

    bird.gotoAndStop(3); //frame 3 = where the die animation is 
    addEventListener(Event.ENTER_FRAME, waitForDeathAnimationToEnd);

}

function waitForDeathAnimationToEnd(e:Event)
{
    if(bird.currentFrame === bird.totalFrames)
    {
        removeEventListener(Event.ENTER_FRAME, waitForDeathAnimationToEnd);
        bird.stop();
        gotoAndStop(frameOrFrameLabelWhereYourGameOverFrameIs); //Replace with Game Over frame label or number
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM