Jump to content

fps drop to 14 when drawing in update function


tproper
 Share

Recommended Posts

I'm using Phaser2 to make a simple game.

When I set the game width and height to these:

var Screen_Width = window.innerWidth * window.devicePixelRatio;
var Screen_Height = window.innerHeight * window.devicePixelRatio;

The game runs really slow on my iPhone. What is the problem?

Link to comment
Share on other sites

Constantly resizing the window every frame is computationally expensive no matter the framework. As a solution, instead of doing this every frame, only do this when the window is resized. Here is a bit of code that may help:

window.addEventListener('resize', <RESIZE_METHOD>);

 

Link to comment
Share on other sites

Thanks. I figured it out. It was because I was doing something stupid in Phaser. I didn't really understand that you create multiple graphics objects for drawing multiple things. Instead I had one graphic object drawing everything and it worked sometimes and not other times.

Thanks again!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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