Skip to content

Commit 15411f1

Browse files
committed
Tween.onLoop would be fired when a Tween repeated and Tween.onRepeat would be fired when a Tween looped. These are now reversed to fire correctly (thanks @vladkens phaserjs#2024)
1 parent 071d9cf commit 15411f1

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
378378
* ctrl + click is now only considered a right-click if event.buttons = 1, this should allow you to use ctrl as a key modifier on Windows (and any device with a multi-button mouse attached) and still use ctrl + click on OS X / trackpads for a right-click (thanks @yuvalsv #2167)
379379
* If the Mouse was over a Sprite and you then clicked it, it would dispatch another Over event. This is now surpressed if the Over event has already been dispatched previously (thanks @McFarts #2133)
380380
* InputHandler.pointerOver could fail to return anything in some instances, now always returns a boolean.
381+
* Tween.onLoop would be fired when a Tween repeated and Tween.onRepeat would be fired when a Tween looped. These are now reversed to fire correctly (thanks @vladkens #2024)
381382

382383
### Pixi Updates
383384

src/tween/Tween.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Phaser.Tween.prototype = {
198198
* @param {function|string} [ease=null] - Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden.
199199
* @param {boolean} [autoStart=false] - Set to `true` to allow this tween to start automatically. Otherwise call Tween.start().
200200
* @param {number} [delay=0] - Delay before this tween will start in milliseconds. Defaults to 0, no delay.
201-
* @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this induvidual tween, not any chained tweens.
201+
* @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens.
202202
* @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.
203203
* @return {Phaser.Tween} This Tween object.
204204
*/
@@ -245,7 +245,7 @@ Phaser.Tween.prototype = {
245245
* @param {function|string} [ease=null] - Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden.
246246
* @param {boolean} [autoStart=false] - Set to `true` to allow this tween to start automatically. Otherwise call Tween.start().
247247
* @param {number} [delay=0] - Delay before this tween will start in milliseconds. Defaults to 0, no delay.
248-
* @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this induvidual tween, not any chained tweens.
248+
* @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens.
249249
* @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.
250250
* @return {Phaser.Tween} This Tween object.
251251
*/
@@ -763,7 +763,14 @@ Phaser.Tween.prototype = {
763763
}
764764
else if (status === Phaser.TweenData.LOOPED)
765765
{
766-
this.onLoop.dispatch(this.target, this);
766+
if (this.repeatCounter === -1)
767+
{
768+
this.onLoop.dispatch(this.target, this);
769+
}
770+
else
771+
{
772+
this.onRepeat.dispatch(this.target, this);
773+
}
767774
return true;
768775
}
769776
else if (status === Phaser.TweenData.COMPLETE)
@@ -798,7 +805,7 @@ Phaser.Tween.prototype = {
798805
if (this.repeatCounter === -1)
799806
{
800807
this.timeline[this.current].start();
801-
this.onRepeat.dispatch(this.target, this);
808+
this.onLoop.dispatch(this.target, this);
802809
return true;
803810
}
804811
else if (this.repeatCounter > 0)

0 commit comments

Comments
 (0)