Jump to content

Is it a clever way to stop and avoid looping the sprite animation ?


khleug35
 Share

Recommended Posts

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

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

Reply back with the .json file if you need more help.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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