Skip to content

Commit ccc4e42

Browse files
committed
A Timer with a delay value that was a float and not an integer would not loop correctly. Timer delay values are now passed through Math.round to avoid this (thanks @osmanzeki phaserjs#1196)
1 parent e0a20ce commit ccc4e42

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Version 2.1.2 - "Whitebridge" - in development
104104
* If you called StateManager.start from within a states `init` method which also had a `preload` method it would fail to start the next State.
105105
* StateManager.boot would call start on a State twice if it was added to the game and started before the DOM load had completed. This didn't cause an error but was duplicating function calls needlessly.
106106
* Changing any of the Text properties such as font, lineSpacing and fontSize on a Text object that wasn't already on the display list would cause an updateTransform error. Parent is now checked first in all setters.
107+
* A Timer with a delay value that was a float and not an integer would not loop correctly. Timer delay values are now passed through Math.round to avoid this (thanks @osmanzeki #1196)
107108

108109

109110
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md

src/time/Timer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Phaser.Timer.prototype = {
169169
* Creates a new TimerEvent on this Timer. Use the methods add, repeat or loop instead of this.
170170
* @method Phaser.Timer#create
171171
* @private
172-
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
172+
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback. This value should be an integer, not a float. Math.round() is applied to it by this method.
173173
* @param {boolean} loop - Should the event loop or not?
174174
* @param {number} repeatCount - The number of times the event will repeat.
175175
* @param {function} callback - The callback that will be called when the Timer event occurs.
@@ -179,6 +179,8 @@ Phaser.Timer.prototype = {
179179
*/
180180
create: function (delay, loop, repeatCount, callback, callbackContext, args) {
181181

182+
delay = Math.round(delay);
183+
182184
var tick = delay;
183185

184186
if (this._now === 0)

0 commit comments

Comments
 (0)