Jump to content

Switching between requestAnimationFrame and setTimeout at run time


Recommended Posts

Hi folks!

So I'm working on an online game, and I'd like the game to continue running when the user changes tabs in their browser.  I can get around the issue by adding forceSetTimeout: true to my config but it makes gameplay quite janky.  Ideally I would use RAF, detect when a tab has changed, and switch to using the setTimeout method... and move back to using RAF once the user opens the tab up again.  Is there anything in place for handling this?  I know it's theoretically possible since I've worked with RAF and raw canvas in the past, I was just curious about the best method to approach this with Phaser.

And before someone suggests it, I'm already setting disableVisibilityChange = true in my config to account for the game losing focus :)  However this is not about losing focus, but changing tabs.

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.

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.


  • Recently Browsing   0 members

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