@@ -266,14 +266,14 @@ var TweenManager = new Class({
266266
267267 /**
268268 * Creates a Stagger function to be used by a Tween property.
269- *
269+ *
270270 * The stagger function will allow you to stagger changes to the value of the property across all targets of the tween.
271- *
271+ *
272272 * This is only worth using if the tween has multiple targets.
273- *
273+ *
274274 * The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2
275275 * over the duration specified:
276- *
276+ *
277277 * ```javascript
278278 * this.tweens.add({
279279 * targets: [ ... ],
@@ -283,10 +283,10 @@ var TweenManager = new Class({
283283 * delay: this.tweens.stagger(100)
284284 * });
285285 * ```
286- *
286+ *
287287 * The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering
288288 * from the center out, using a cubic ease.
289- *
289+ *
290290 * ```javascript
291291 * this.tweens.add({
292292 * targets: [ ... ],
@@ -541,44 +541,61 @@ var TweenManager = new Class({
541541 /**
542542 * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets.
543543 *
544+ * Only the currently active tweens are tested. A tween that has completed and is
545+ * awaiting removal will not be included in the results.
546+ *
547+ * If you wish to also search pending tweens, use the `includePending` flag.
548+ *
544549 * @method Phaser.Tweens.TweenManager#getTweensOf
545550 * @since 3.0.0
546551 *
547552 * @param {(object|array) } target - The target to look for. Provide an array to look for multiple targets.
553+ * @param {boolean } [includePending=false] - Also check for pending tweens, not just active ones?
548554 *
549555 * @return {Phaser.Tweens.Tween[] } A new array containing all Tweens and Timelines which affect the given target(s).
550556 */
551- getTweensOf : function ( target )
557+ getTweensOf : function ( target , includePending )
552558 {
559+ if ( includePending === undefined ) { includePending = false ; }
560+
553561 var list = this . _active ;
554562 var tween ;
555563 var output = [ ] ;
556564 var i ;
565+ var t ;
557566
558- if ( Array . isArray ( target ) )
567+ if ( ! Array . isArray ( target ) )
559568 {
560- for ( i = 0 ; i < list . length ; i ++ )
561- {
562- tween = list [ i ] ;
569+ target = [ target ] ;
570+ }
571+
572+ for ( i = 0 ; i < list . length ; i ++ )
573+ {
574+ tween = list [ i ] ;
563575
564- for ( var t = 0 ; t < target . length ; t ++ )
576+ for ( t = 0 ; t < target . length ; t ++ )
577+ {
578+ if ( tween . hasTarget ( target [ t ] ) )
565579 {
566- if ( tween . hasTarget ( target [ t ] ) )
567- {
568- output . push ( tween ) ;
569- }
580+ output . push ( tween ) ;
570581 }
571582 }
572583 }
573- else
584+
585+ if ( includePending )
574586 {
587+ list = this . _pending ;
588+
575589 for ( i = 0 ; i < list . length ; i ++ )
576590 {
577591 tween = list [ i ] ;
578592
579- if ( tween . hasTarget ( target ) )
593+ for ( t = 0 ; t < target . length ; t ++ )
580594 {
581- output . push ( tween ) ;
595+ if ( tween . hasTarget ( target [ t ] ) )
596+ {
597+ output . push ( tween ) ;
598+ }
582599 }
583600 }
584601 }
0 commit comments