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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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