Jump to content

Phaser unrendered (headless) updates for simulation


Navarre
 Share

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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...