Jump to content

Periodically Pausing Animation


Recommended Posts

On my game's menu screen I needed an animation that runs for a while then pauses for a pre-decided amount of time and then runs again. I couldn't find a function in the API to do this so I ended up with these two options - 



var frames = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];for( var i = 0; i < 100; i++ ) {         frames.push(27);}laser1 = this.game.add.sprite( 0, 30, 'laser');laser1.animations.add( 'shoot', frames );laser1.animations.play( 'shoot', 30, true );


laser1 = this.game.add.sprite( 0, 30, 'laser');laser1.animations.add( 'shoot' );laser1.animations.play( 'shoot', 30, false );laser1.events.onAnimationComplete.add( function () {    foo();} );function foo () {    setTimeout( function () {        laser1.animation.play( 'shoot', 30, false);    }, 2000 )}

I am not sure which one is better or if there is some other way I should be doing this. Did I not read the documentation properly and there already is a way to do this with Phaser?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...