@@ -148,22 +148,8 @@ var BaseSoundManager = new Class({
148148 */
149149 this . unlocked = false ;
150150
151- game . events . on ( GameEvents . BLUR , function ( )
152- {
153- if ( this . pauseOnBlur )
154- {
155- this . onBlur ( ) ;
156- }
157- } , this ) ;
158-
159- game . events . on ( GameEvents . FOCUS , function ( )
160- {
161- if ( this . pauseOnBlur )
162- {
163- this . onFocus ( ) ;
164- }
165- } , this ) ;
166-
151+ game . events . on ( GameEvents . BLUR , this . onGameBlur , this ) ;
152+ game . events . on ( GameEvents . FOCUS , this . onGameFocus , this ) ;
167153 game . events . on ( GameEvents . PRE_STEP , this . update , this ) ;
168154 game . events . once ( GameEvents . DESTROY , this . destroy , this ) ;
169155 } ,
@@ -505,6 +491,36 @@ var BaseSoundManager = new Class({
505491 */
506492 onFocus : NOOP ,
507493
494+ /**
495+ * Internal handler for Phaser.Core.Events#BLUR.
496+ *
497+ * @method Phaser.Sound.BaseSoundManager#onGameBlur
498+ * @private
499+ * @since 3.23.0
500+ */
501+ onGameBlur : function ( )
502+ {
503+ if ( this . pauseOnBlur )
504+ {
505+ this . onBlur ( ) ;
506+ }
507+ } ,
508+
509+ /**
510+ * Internal handler for Phaser.Core.Events#FOCUS.
511+ *
512+ * @method Phaser.Sound.BaseSoundManager#onGameFocus
513+ * @private
514+ * @since 3.23.0
515+ */
516+ onGameFocus : function ( )
517+ {
518+ if ( this . pauseOnBlur )
519+ {
520+ this . onFocus ( ) ;
521+ }
522+ } ,
523+
508524 /**
509525 * Update method called on every game step.
510526 * Removes destroyed sounds and updates every active sound in the game.
@@ -549,6 +565,10 @@ var BaseSoundManager = new Class({
549565 */
550566 destroy : function ( )
551567 {
568+ this . game . events . off ( GameEvents . BLUR , this . onGameBlur , this ) ;
569+ this . game . events . off ( GameEvents . FOCUS , this . onGameFocus , this ) ;
570+ this . game . events . off ( GameEvents . PRE_STEP , this . update , this ) ;
571+
552572 this . removeAllListeners ( ) ;
553573
554574 this . removeAll ( ) ;
0 commit comments