Navarre Posted March 19, 2017 Share Posted March 19, 2017 I would like to use Phaser in headless mode (i.e. update world at a higher rate than screen update frequency, without anything getting drawn to screen) to simulate many times an environment. I couldn't get anywhere in the docs how to use it: if you set HEADLESS mode in Game creation no update is done: how can one manually call Phaser game ticks? I think even Phaser.CANVAS mode can be suitable for the job: but how can one disable rendering and bind any update to a looping function faster than requestAnimationFrame? Link to comment Share on other sites More sharing options...
samme Posted March 19, 2017 Share Posted March 19, 2017 Are you doing no rendering at all, ever (such as server-side)? Or is it just a regular game where you want to render 60fps, update 120fps? Link to comment Share on other sites More sharing options...
samme Posted March 19, 2017 Share Posted March 19, 2017 9 hours ago, Navarre said: if you set HEADLESS mode in Game creation no update is done: how can one manually call Phaser game ticks? HEADLESS doesn't prevent updates, but if you're running without window.requestAnimationFrame or window.setTimeout then that might. Link to comment Share on other sites More sharing options...
Navarre Posted March 20, 2017 Author Share Posted March 20, 2017 Thanks for your reply! What I would like to achieve is running Phaser logic (graphics update - e.g. color transition, world physics, timers, and so on) at a frequency which is NOT limited by graphics rendering but instead it's just the maximum a browser can achieve. This would be useful for e.g. a simulation that I have to execute thousands of times (e.g. a Montecarlo simulation), in which you are just interested in the final results and not in the single realizations. So for your question: no, I never need a rendering. I just need a way to instance a Phaser world, create a game, execute that game in headless mode and "do things" in the update function. "Do things" can be for everything from computing stats for later analysis or change simulation setup. I'd like to know if there's a proper way to do it without modifying Phaser. Link to comment Share on other sites More sharing options...
samme Posted March 20, 2017 Share Posted March 20, 2017 You can try something like http://codepen.io/samme/pen/jBZvyK?editors=0010 (JS: http://s.codepen.io/samme/debug/jBZvyK/PNkvYLEJeGyA). It needs a little more work to run timers manually. Navarre 1 Link to comment Share on other sites More sharing options...
Navarre Posted March 22, 2017 Author Share Posted March 22, 2017 Thanks! I'll give it a try ASAP. Link to comment Share on other sites More sharing options...
Recommended Posts