Skip to main content
Participant
October 6, 2019
Answered

Animate html5 canvas - how to pause frame for 10 seconds and then automatically continue animation

  • October 6, 2019
  • 2 replies
  • 1979 views

I can't seem to figure out how to pause the animation for 10 seconds at a given frame and after 10 seconds the animation continues. I can get it to stop using:

 

this.stop();

 

but how do I add a time of 10 seconds to start again?

 

Thanks.

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Use the setTimeout method.

     

    Like this:

    var target = this; // the target Movie Clip instance you want to pause
    
    target.stop();
    
    window.setTimeout(function()
    {
        target.play();
    }, 1000 * 10); // time in milliseconds. Each second is equal to 1000 milliseconds

     

     

    Regards,

    JC

    2 replies

    12222305Author
    Participant
    October 6, 2019

    Perfect. Thank you.

    JoãoCésar17023019
    Community Expert
    Community Expert
    October 7, 2019
    You're welcome!
    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    October 6, 2019

    Hi.

     

    Use the setTimeout method.

     

    Like this:

    var target = this; // the target Movie Clip instance you want to pause
    
    target.stop();
    
    window.setTimeout(function()
    {
        target.play();
    }, 1000 * 10); // time in milliseconds. Each second is equal to 1000 milliseconds

     

     

    Regards,

    JC