Jump to content

Phaser Animation Playback Examples


Recommended Posts

I've been trying to use animations and run into issues. I have two animations 'up' and 'down' which are reverse of each other.


Now i am running animation 'up' then i stop 'up' and play 'down'. But then 'down' animation should start where 'up' left off.


I haven't found many examples of animation playback. How can i do this? Here's my current implementation which seems to be working fine, but i am not sure.

    MySprite.prototype.down = function() {        // animation to be played        var a = this.animations.getAnimation('down');        // What's the difference between these they don't match        //console.log(this.animations.currentFrame);        //console.log(this.animations.currentAnim.currentFrame);        // save the previous animation frame        var cf = this.animations.currentAnim.currentFrame.name;        // stop the current animation        this.animations.currentAnim.stop();        // this is bad        //a.play();        // I don't know what this does, but it gives error, something about PIXI.TextureCache        //this.animations.refreshFrame();        // can't call setFrame before playing the animation        // a.setFrame(cf);        // call the animation manager to play        this.animations.play('down');        // currentAnim is changed        //a.setFrame(this.animations.currentAnim.currentFrame.name);        a.setFrame(cf);        // calling set frame with a number doesn't work        //a.setFrame(10);        // a local index can be used        //a.setFrame(10, true);   };
Link to comment
Share on other sites


  • Recently Browsing   0 members

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