Game pause when change tabs or minium browser

Game pause when change tabs or minium browser
0.0 0


When I change tabs web or minium browser , game will pause and It will run continus when I open game tabs. but I want it run even change tabs or miniun browser. someone help me please. thanks!


Cocos2d-html5 use requestAnimFrame for main loop. It will automatically pause the update/draw.

So, if you want your game keeping running, you should switch requestAnimFrame to setInterval, and disable the audio pausing.
Please refer to /cocos2d-html5/cocos2d/core/platform/CCApplication.js line 375 and line 258.


Thanks ShunLin, sound is good, I changed function like this but It still not run when change tabs or minium:

run:function () {
// Initialize instance and cocos2d.
if (!this.applicationDidFinishLaunching()) return 0;
var callback, director = cc.Director.getInstance(), w = window;
cc.director = director;
callback = function () {
setInterval(callback, this._animationInterval * 1000);
return 0;


How to do that in cocos2d html5 v3.8 ?


How to do that in cocos2d html5 v3.10? :frowning:


Check CCBoot.js line no - 2480.
frame rate config check is there if frame rate is not 60.


Line no 2713 in CCBoot.js

Comment these line if you want your game to run even if tab is changed.

    var onHidden = function () {
        /*if (cc.eventManager &&
    var onShow = function () {
        /*if (cc.eventManager &&


Music keeps playing if I leave cocos js window open and go editing code for example , how do I solve that ?
Chromium on Ubuntu linux .