Sign in to follow this  
Navarre

Phaser unrendered (headless) updates for simulation

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.