Skip to content

Commit 38a224d

Browse files
committed
Tween.delay, Tween.repeat and Tween.yoyo will no longer throw an error if called before a TweenData object has been created (via Tween.to or Tween.from) (thanks @SomMeri phaserjs#1419)
1 parent e7f3b91 commit 38a224d

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- [How to Build](#how-to-build)
1010
- [Koding](#koding)
1111
- [Bower / NPM](#bower)
12-
- [CDNJS](#cdnjs)
12+
- [jsDelivr](#jsdelivr)
1313
- [Requirements](#requirements)
1414
- [Build Files](#build-files)
1515
- [Learn By Example](#example)
@@ -79,6 +79,8 @@ Version 2.2.2 - "Alkindar" - in development
7979

8080
### Bug Fixes
8181

82+
* Tween.delay, Tween.repeat and Tween.yoyo will no longer throw an error if called before a TweenData object has been created (via Tween.to or Tween.from) (thanks @SomMeri #1419)
83+
8284
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
8385

8486
![div](http://phaser.io/images/div3.png)
@@ -124,16 +126,18 @@ Nice and easy :)
124126

125127
![div](http://phaser.io/images/div6.png)
126128

127-
<a name="cdnjs"></a>
128-
## CDNJS
129+
<a name="jsdelivr"></a>
130+
## jsDelivr
131+
132+
Phaser is now available on [jsDelivr](http://jsdelivr.com) - a "super-fast CDN for developers and webmasters." You can include the following in your html:
129133

130-
Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
134+
`//cdn.jsdelivr.net/phaser/2.2.2/phaser.min.js`
131135

132-
`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.2.2/phaser.min.js`
136+
or the non-minified version:
133137

134-
Or if you prefer you can leave the protocol off, so it works via http and https:
138+
`//cdn.jsdelivr.net/phaser/2.2.2/phaser.js`
135139

136-
`//cdnjs.cloudflare.com/ajax/libs/phaser/2.2.2/phaser.min.js`
140+
More details on the [jsDelivr Phaser page](http://www.jsdelivr.com/#!phaser).
137141

138142
![div](http://phaser.io/images/div1.png)
139143

src/tween/Tween.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ Phaser.Tween.prototype = {
359359
/**
360360
* Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts.
361361
* The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
362+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay.
362363
* If you have child tweens and pass -1 as the index value it sets the delay across all of them.
363364
*
364365
* @method Phaser.Tween#delay
@@ -368,6 +369,8 @@ Phaser.Tween.prototype = {
368369
*/
369370
delay: function (duration, index) {
370371

372+
if (this.timeline.length === 0) { return this; }
373+
371374
if (typeof index === 'undefined') { index = 0; }
372375

373376
if (index === -1)
@@ -388,6 +391,7 @@ Phaser.Tween.prototype = {
388391

389392
/**
390393
* Sets the number of times this tween will repeat.
394+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to repeat.
391395
* If you have child tweens and pass -1 as the index value it sets the number of times they'll repeat across all of them.
392396
* If you wish to define how many times this Tween and all children will repeat see Tween.repeatAll.
393397
*
@@ -398,6 +402,8 @@ Phaser.Tween.prototype = {
398402
*/
399403
repeat: function (total, index) {
400404

405+
if (this.timeline.length === 0) { return this; }
406+
401407
if (typeof index === 'undefined') { index = 0; }
402408

403409
if (index === -1)
@@ -419,6 +425,7 @@ Phaser.Tween.prototype = {
419425
/**
420426
* A Tween that has yoyo set to true will run through from its starting values to its end values and then play back in reverse from end to start.
421427
* Used in combination with repeat you can create endless loops.
428+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to yoyo.
422429
* If you have child tweens and pass -1 as the index value it sets the yoyo property across all of them.
423430
* If you wish to yoyo this Tween and all of its children then see Tween.yoyoAll.
424431
*
@@ -429,6 +436,8 @@ Phaser.Tween.prototype = {
429436
*/
430437
yoyo: function(enable, index) {
431438

439+
if (this.timeline.length === 0) { return this; }
440+
432441
if (typeof index === 'undefined') { index = 0; }
433442

434443
if (index === -1)

0 commit comments

Comments
 (0)