Physic body wrong position with Game resolution pixel ratio

Recommended Posts

Hi Phaser community,

It is my first project with Phaser, I am struggling with devicePixelRatio and physics (arcade) body on ipad. 

When I set the Phaser.Game resolution to 2 (iPad pixel ratio) my sprites are resizing correctly, but the bodies are still positioned as if the resolution was 1. So the body are not positioned on sprites.

Does this ring anyone's bell ? 

How could I match the body position with the sprite position ?

Thank you




Share this post

Link to post
Share on other sites

I don't really understand how game.resolution is supposed to work with sprite textures.

If you use game.resolution=2 and a 100 ×100 image, the sprite is drawn at 100 ×100 renderer px → 50×50 game px, but the sprite's dimensions (width, height) are still 100×100 game px.


Share this post

Link to post
Share on other sites

Hi Samme,

Thank you for looking into it, I was thinking that resolution was used for device pixel ratio, but I also found the same positioning problem with the inputs debug, they are drawn as if the world was in resolution 1.

I finally found a solution, I keep the resolution to 1 and set scaleMode to USER_SCALE and set the user scale to 0.5  (would be 1/devicePixelRatio for other devices)

this.scale.scaleMode = Phaser.ScaleManager.USER_SCALE;


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.

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.