@@ -132,13 +132,26 @@ Phaser.Tween = function (object, game) {
132132 */
133133 this . _onUpdateCallbackContext = null ;
134134
135+ /**
136+ * @property {boolean } _paused - Is this Tween paused or not?
137+ * @private
138+ * @default
139+ */
140+ this . _paused = false ;
141+
135142 /**
136143 * @property {number } _pausedTime - Private pause timer.
137144 * @private
138145 * @default
139146 */
140147 this . _pausedTime = 0 ;
141148
149+ /**
150+ * @property {boolean } _codePaused - Was the Tween paused by code or by Game focus loss?
151+ * @private
152+ */
153+ this . _codePaused = false ;
154+
142155 /**
143156 * @property {boolean } pendingDelete - If this tween is ready to be deleted by the TweenManager.
144157 * @default
@@ -436,28 +449,59 @@ Phaser.Tween.prototype = {
436449 */
437450 pause : function ( ) {
438451
452+ this . _codePaused = true ;
439453 this . _paused = true ;
440454 this . _pausedTime = this . game . time . now ;
441455
442456 } ,
443457
458+ /**
459+ * This is called by the core Game loop. Do not call it directly, instead use Tween.pause.
460+ * @method Phaser.Tween#_pause
461+ * @private
462+ */
463+ _pause : function ( ) {
464+
465+ if ( ! this . _codePaused )
466+ {
467+ this . _paused = true ;
468+ this . _pausedTime = this . game . time . now ;
469+ }
470+
471+ } ,
472+
444473 /**
445474 * Resumes a paused tween.
446475 *
447476 * @method Phaser.Tween#resume
448- * @param {boolean } [fromManager=false] - Did this resume request come from the TweenManager or game code?
449477 */
450- resume : function ( fromManager ) {
478+ resume : function ( ) {
451479
452- this . _paused = false ;
453-
454- if ( typeof fromManager === 'undefined' || ! fromManager )
480+ if ( this . _paused )
455481 {
482+ this . _paused = false ;
483+ this . _codePaused = false ;
484+
456485 this . _startTime += ( this . game . time . now - this . _pausedTime ) ;
457486 }
487+
488+ } ,
489+
490+ /**
491+ * This is called by the core Game loop. Do not call it directly, instead use Tween.pause.
492+ * @method Phaser.Tween#_resume
493+ * @private
494+ */
495+ _resume : function ( ) {
496+
497+ if ( this . _codePaused )
498+ {
499+ return ;
500+ }
458501 else
459502 {
460503 this . _startTime += this . game . time . pauseDuration ;
504+ this . _paused = false ;
461505 }
462506
463507 } ,
0 commit comments