Jump to content

Periodically Pausing Animation


prtksxna
 Share

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 - 

 

Option1

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 );

Option2

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

 Share

  • Recently Browsing   0 members

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