codevinsky Posted February 25, 2014 Share Posted February 25, 2014 I'm building an idle-type game and it's imperative that it runs while not the active browser tab. Link to comment Share on other sites More sharing options...
rich Posted February 26, 2014 Share Posted February 26, 2014 You can do this using a game configuration object and set the property forceSetTimeOut to true. Understand that some browsers will still pause the game for you though, regardless. iOS in particular will freeze all JavaScript execution when you swap out or to another tab, no matter how you update the game. Link to comment Share on other sites More sharing options...
codevinsky Posted February 26, 2014 Author Share Posted February 26, 2014 Is this only on 1.1.6? Either I'm doing it wrong: game.config = { forceSetTimeOut: true; }Or 1.1.5 doesn't have this capability. Can I get an example of how I'd use the game config property correctly? Link to comment Share on other sites More sharing options...
Telash Posted February 26, 2014 Share Posted February 26, 2014 Isn't this what you want? Or am I misunderstanding something? // Phaser will automatically pause if the browser tab the game is in loses focus. You can disable that here: this.game.stage.disableVisibilityChange = true; Link to comment Share on other sites More sharing options...
codevinsky Posted February 26, 2014 Author Share Posted February 26, 2014 That works if the game is in it's own window and it's not the active window. But if it's in a tab (Chrome), and you switch tabs, it still pauses play. Link to comment Share on other sites More sharing options...
rich Posted February 26, 2014 Share Posted February 26, 2014 game config was introduced in 1.1.4. Here is how you'd do it:var config = { width: 800, height: 600, renderer: Phaser.AUTO, parent: 'yourDivID', transparent: false, antialias: true, forceSetTimeOut: true}var game = new Phaser.Game(config);// now add your states here Link to comment Share on other sites More sharing options...
codevinsky Posted February 27, 2014 Author Share Posted February 27, 2014 I've done this, but it's still using raf. I've checked source, no where in 1.1.5 is "forceSetTimeout" referenced. I'd expect to see it in the Phaser.Game.Prototype.parseConfig method. Link to comment Share on other sites More sharing options...
rich Posted February 27, 2014 Share Posted February 27, 2014 Never mind then. Game config was introduced in 1.1.4, but forceSetTimeout was obviously something I added for 1.2. You do realise it's going to cause quite janky rendering by using it though, right? Link to comment Share on other sites More sharing options...
codevinsky Posted February 27, 2014 Author Share Posted February 27, 2014 Yeah I do. It's an idle game, though. It absolutely must run in the background. I might jack around with source until i get exactly what I want with it. Perhaps I'll run RAF while screen is visible, and setTimeout when it's not. Example: http://static.codevinsky.com Link to comment Share on other sites More sharing options...
codevinsky Posted February 27, 2014 Author Share Posted February 27, 2014 Oh. I read your previous comment as 1.1.2, not 1.2. Maybe I'll check it out. Link to comment Share on other sites More sharing options...
Recommended Posts