Jump to content

Accommodating different pixel densities


jamessimo
 Share

Recommended Posts

Hey guys, I made a game on my Macbook pro, I use scale.set() in many places and use the screens height/width to help place sprites.

The problem is that my Macbook has a retina screen (which has a pixel density of 2.0). When I play my game on a non-retina (normal 1.0) screen the game is blown up to look massive. 

The way to fix it would be to divide any numbers I use for size/position by the pixel density. This however seems weird as I have to have this everywhere 

somevar * game.device.pixelRatio

Is there a way to do this better? 

Link to comment
Share on other sites

How are you getting the screen width/height?

As far as the browser is concerned it already takes into account the pixel density. i.e. 2560px retina screen will act as if it was 1280px.

If you want your game to support retina the easiest way is:

set the phaser game size to double the required size and then use canvas.width and canvas.height to set it back to the original size.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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