Skip to content

Commit 022d709

Browse files
committed
jsdoc fixes and frameRate change.
1 parent bee0e73 commit 022d709

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Version 2.1.3 - "Ravinda" - in development
7878

7979
### Updates
8080

81+
* Changed the Animation constructor parameter `delay` to `frameRate` as it's a more accurate term of what it should be. Internally nothing changed.
8182

8283
### Bug Fixes
8384

src/animation/Animation.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
* @param {string} name - The unique name for this animation, used in playback commands.
1616
* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
1717
* @param {number[]|string[]} frames - An array of numbers or strings indicating which frames to play in which order.
18-
* @param {number} delay - The time between each frame of the animation, given in ms.
18+
* @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second.
19+
* @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once.
1920
* @param {boolean} loop - Should this animation loop when it reaches the end or play through once.
2021
*/
21-
Phaser.Animation = function (game, parent, name, frameData, frames, delay, loop) {
22+
Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, loop) {
23+
24+
if (typeof loop === 'undefined') { loop = false; }
2225

2326
/**
2427
* @property {Phaser.Game} game - A reference to the currently running Game.
@@ -50,9 +53,9 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loop)
5053
this._frames = this._frames.concat(frames);
5154

5255
/**
53-
* @property {number} delay - The delay in ms between each frame of the Animation.
56+
* @property {number} delay - The delay in ms between each frame of the Animation, based on the given frameRate.
5457
*/
55-
this.delay = 1000 / delay;
58+
this.delay = 1000 / frameRate;
5659

5760
/**
5861
* @property {boolean} loop - The loop state of the Animation.
@@ -677,7 +680,7 @@ Object.defineProperty(Phaser.Animation.prototype, 'frame', {
677680

678681
/**
679682
* @name Phaser.Animation#speed
680-
* @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.
683+
* @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Minimum value is 1.
681684
*/
682685
Object.defineProperty(Phaser.Animation.prototype, 'speed', {
683686

0 commit comments

Comments
 (0)