Sign in to follow this  
jamessimo

Accommodating different pixel densities

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? 

Share this post


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

 

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.