prtksxna Posted March 7, 2014 Share Posted March 7, 2014 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 - Option1var 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 );Option2laser1 = 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 More sharing options...
prtksxna Posted March 7, 2014 Author Share Posted March 7, 2014 Did some more reading, I guess the right way to do this would be by using a basic looped event? Though I did notice that example going a bit crazy if I switched tabs for a while (couldn't reproduce the bug every time) Link to comment Share on other sites More sharing options...
Recommended Posts