eggborne Posted May 4, 2014 Share Posted May 4, 2014 I have asked around about this and haven't had much success; it was suggested that the framework I'm using has its own version of this functionality. So here I am! I know it's best for most games to automatically pause when focus is lost, but I'm working on a cellular automata and I want it to continue running at all times. Is this possible? Quote Link to comment Share on other sites More sharing options...
giraluna Posted May 4, 2014 Share Posted May 4, 2014 This isn't a PIXI issue at all. You need to write the logic update function to take into account the time passed since last logic tick. Then advance the simulation by how many ticks fit in the accumulated time. More in depth article: http://gafferongames.com/game-physics/fix-your-timestep/ Quote Link to comment Share on other sites More sharing options...
eggborne Posted May 4, 2014 Author Share Posted May 4, 2014 So you're saying the simulation would still be frozen when not in focus, but would "catch up" on all its operations when the user brought the window back into focus? Wouldn't there be a point where so many update() calls (i.e. many hours' worth) would hang the browser? Quote Link to comment Share on other sites More sharing options...
xerver Posted May 4, 2014 Share Posted May 4, 2014 If you use setTimeout/setInterval instead of using requestAnimationFrame it will continue even when the browser is blurred. Quote Link to comment Share on other sites More sharing options...
giraluna Posted May 4, 2014 Share Posted May 4, 2014 I assumed you meant the browser limiting calls to setInterval or requestAnimationFrame when it's not focused, which is what at least most desktop browsers do. In that case the simulation would update less frequently but would do bigger chunks at once to keep up. If the program stops completely when you lose focus it's probably your browser or some non-pixi framework. Check if there's any listeners for "blur" events. (On chrome F12 > Elements > event listeners) Quote Link to comment Share on other sites More sharing options...
eggborne Posted May 4, 2014 Author Share Posted May 4, 2014 Thanks for the replies, guys. I seem to constantly come here with non-Pixi problems. Upon further inspection it seems that the game runs very slowly when the browser is blurred (I am using setTimeout), a tiny fraction of the normal speed -- it took about a minute to update 50 times, when it normally would have updated 3600 or so in that span. Do you know of any way to control this? Quote Link to comment Share on other sites More sharing options...
xerver Posted May 4, 2014 Share Posted May 4, 2014 Thanks for the replies, guys. I seem to constantly come here with non-Pixi problems. Upon further inspection it seems that the game runs very slowly when the browser is blurred (I am using setTimeout), a tiny fraction of the normal speed -- it took about a minute to update 50 times, when it normally would have updated 3600 or so in that span. Do you know of any way to control this? Nope, this is by design. You will have to compensate. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.