var Animation = function (parent){ this.parent = parent; this.animationManager = parent.state.sys.anims; this.isPlaying = false ; this.currentAnim = null ; this.currentFrame = null ; this.accumulator = 0; this.nextTick = 0; } ; Animation.prototype.constructor = Animation; Animation.prototype = { load: function (key, startFrame){ if (startFrame === undefined) { startFrame = 0; } if (this.isPlaying) { this.stop(); } _AN_Call_load('load', this.animationManager, this, key, startFrame); this.updateFrame(); } , play: function (key, startFrame){ if (startFrame === undefined) { startFrame = 0; } _AN_Call_load('load', this, key, startFrame); this.accumulator = 0; this.currentAnim.getNextTick(this); this.isPlaying = true ; } , stop: function (){ this.isPlaying = false ; } , updateFrame: function (){ this.parent.texture = this.currentFrame.frame.texture; this.parent.frame = this.currentFrame.frame; } , update: function (timestamp, frameDelta){ if (this.isPlaying) { this.accumulator += frameDelta; if (this.accumulator >= this.nextTick) { this.currentAnim.setFrame(this); } } } } ; module.exports = Animation;