Sign in to follow this  
khleug35

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

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
}

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.