Jump to content

Phaser Canvas (Inner) Resolution & Button Clickable Areas


Rorian
 Share

Recommended Posts

Hey guys,

 

I've started with Phaser today and I wonder if changing Canvas resolution while the game is running affects the Button Clickable Areas. When I change Canvas resolution everything is positioned alright only button clickable areas act somehow funky.

 

I've uploaded example of what I'm talking about:


 

- click the Phaser logo and Canvas resolution will be doubled while everything will be scaled and positioned properly again

- click it again and... nothing happens... you have to move your mouse somewhere in the lower right corner and click there (basically the clickable area of the button has moved)... and then everything goes back to normal

 

I've tried changing the canvas resolution before I've initialized the game and everything run smoothly. The problem is when I try to change it while the game is already running.

 

Thanks~

Link to comment
Share on other sites

I've figured this already. In case if anybody wonder why this happened, here is the solution:

 

 

If you want to change renderer size:

game.renderer.resize()

Then you have to also update the canvas size and set new world bounds:

game.scale.setGameSize()game.world.setBounds()

Then all works fine. But a little warning - your coords do change as well (because you basically set new resolution).

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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