File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -2132,8 +2132,11 @@ cc.game = /** @lends cc.game# */{
21322132 * Pause the game.
21332133 */
21342134 pause : function ( ) {
2135+ if ( this . _paused ) return ;
21352136 this . _paused = true ;
2136-
2137+ // Pause audio engine
2138+ cc . audioEngine . _pausePlaying ( ) ;
2139+ // Pause main loop
21372140 if ( this . _intervalId )
21382141 window . cancelAnimationFrame ( this . _intervalId ) ;
21392142 this . _intervalId = 0 ;
@@ -2143,7 +2146,11 @@ cc.game = /** @lends cc.game# */{
21432146 * Resume the game from pause.
21442147 */
21452148 resume : function ( ) {
2149+ if ( ! this . _paused ) return ;
21462150 this . _paused = false ;
2151+ // Resume audio engine
2152+ cc . audioEngine . _resumePlaying ( ) ;
2153+ // Resume main loop
21472154 this . _runMainLoop ( ) ;
21482155 } ,
21492156
@@ -2528,18 +2535,10 @@ cc.game = /** @lends cc.game# */{
25282535 }
25292536
25302537 cc . eventManager . addCustomListener ( cc . game . EVENT_HIDE , function ( ) {
2531- cc . audioEngine . _pausePlaying ( ) ;
2532- } ) ;
2533- cc . eventManager . addCustomListener ( cc . game . EVENT_SHOW , function ( ) {
2534- cc . audioEngine . _resumePlaying ( ) ;
2538+ cc . game . pause ( ) ;
25352539 } ) ;
2536-
25372540 cc . eventManager . addCustomListener ( cc . game . EVENT_SHOW , function ( ) {
2538- if ( self . _intervalId ) {
2539- window . cancelAnimationFrame ( self . _intervalId ) ;
2540-
2541- self . _runMainLoop ( ) ;
2542- }
2541+ cc . game . resume ( ) ;
25432542 } ) ;
25442543 }
25452544} ;
You can’t perform that action at this time.
0 commit comments