khleug35 Posted March 22, 2018 Share Posted March 22, 2018 Is it a clever way to stop and avoid looping the sprite animation ? The following is my code function update(){ if (cursors.down.isDown) { crouch = true; if(crouch){ player.animations.play('crouch'); //set the time to aviod the animation looping game.time.events.add(Phaser.Timer.SECOND * 0.12, this.animations_Stop, this); } } if (cursors.down.isUp) { crouch = false; } } function animations_Stop () { player.animations.paused = true; // stop the animation } Link to comment Share on other sites More sharing options...
flow Posted March 22, 2018 Share Posted March 22, 2018 The animation can be played looping or non-looping: sprite.animations.play(name [, frameRate] [, loop] [, killOnComplete]) https://photonstorm.github.io/phaser-ce/Phaser.AnimationManager.html#play Is that what you need here? Link to comment Share on other sites More sharing options...
3man7 Posted March 22, 2018 Share Posted March 22, 2018 in create(): //add the animation player.animations.add('crouch', Phaser.Animation.generateFrameNames(prefix, start, stop, suffix, zeroPad), fps, loop); //play the animation player.animations.play('crouch'); https://phaser.io/docs/2.6.2/Phaser.Animation.html https://phaser.io/docs/2.6.2/Phaser.Animation.html#.generateFrameNames Reply back with the .json file if you need more help. Link to comment Share on other sites More sharing options...
Recommended Posts