Jump to content

game blurred in a retina ipad


manelis
 Share

Recommended Posts

Hello,

 

Yesterday I tried for the first time to run my project in a retina ipad, however everything inside the canvas gets completely blurred, even text. Anyone knows what is happening here?

 

First image is on windows chrome with 100% scale, second image is a ipad 3 on safari.

 

post-12404-0-05764100-1435330818_thumb.p

 

post-12404-0-92516800-1435331067_thumb.p

 

Thank you for the help.

Link to comment
Share on other sites

My guess is that it isn't using the correct pixel ratio for the device.

http://stackoverflow.com/questions/15661339/how-do-i-fix-blurry-text-in-my-html5-canvas

 

You should get the device ratio with this function

var PIXEL_RATIO = (function () {
var ctx = document.createElement("canvas").getContext("2d"),
dpr = window.devicePixelRatio || 1,
bsr = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;

return dpr / bsr;
})();

 

 

 

And then apply it to the renderer.context

ratio = PIXEL_RATIO;

renderer.context.setTransform(ratio, 0, 0, ratio, 0 ,0);

Link to comment
Share on other sites

That is probably it. I have the canvas always with the size of the window:

      var width = window.innerWidth;      var height = window.innerHeight;      renderer.view.style.width = width + "px";      renderer.view.style.height = height + "px";      renderer.resize(width, height);

So probably that will fix it. Tomorrow I will try it and give back feedback, ty for the help.

Link to comment
Share on other sites

Ok ended up doing it now. its works but its not with:

renderer.context.setTransform(ratio, 0, 0, ratio, 0 ,0);

you actually pass the ratio to the renderer initialization:

renderer = PIXI.autoDetectRenderer(400, 300, {antialias: true, transparent: true, resolution: ratio});
Link to comment
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...
 Share

  • Recently Browsing   0 members

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