Animation.speed added. You can now change the animation speed on the fly, without re-starting the animation (feature request #458)

This commit is contained in:
photonstorm
2014-02-28 04:32:12 +00:00
parent e3d53ad6a3
commit 8dc28f4800
3 changed files with 72 additions and 0 deletions
+23
View File
@@ -466,6 +466,29 @@ Object.defineProperty(Phaser.Animation.prototype, 'frame', {
});
/**
* @name Phaser.Animation#speed
* @property {number} speed - Gets or sets the current speed of the animation, the time between each frame of the animation, given in ms. Takes effect from the NEXT frame. Minimum value is 1.
*/
Object.defineProperty(Phaser.Animation.prototype, 'speed', {
get: function () {
return Math.round(1000 / this.delay);
},
set: function (value) {
if (value >= 1)
{
this.delay = 1000 / value;
}
}
});
/**
* Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers.
* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large'