Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loss of sprite quality on mobile #1280

Open
yanballas opened this issue Feb 20, 2024 · 1 comment
Open

loss of sprite quality on mobile #1280

yanballas opened this issue Feb 20, 2024 · 1 comment

Comments

@yanballas
Copy link

yanballas commented Feb 20, 2024

Hi guys. I'm using matter.js for some small animation. Depending on the width of the screen, I render four different options for filling the canvas from prepared objects with a fixed width and height of the elements.

const createElement = (x, y, width, height, img) => { const el = Bodies.rectangle(x, y, width, height, { render: { sprite: { texture: img, }, }, }); Composite.add(engine.world, el); };

...some code...

  const respawn = (width) => {
    if (width >= 1200) {
      elementsRespawn(desktopElements);
    } else if (width >= 700) {
      elementsRespawn(tabletElements);
    } else if (width >= 500) {
      elementsRespawn(mobileXlElements);
    } else if (width >= 320) {
      elementsRespawn(mobileSmElements);
    }
  };

I have the following problem. On desktop everything is fine, but on mobile all the images are blurry. It's as if they or canvas have scale.
What do I need to work with?
Thank you.

@yanballas
Copy link
Author

I found that this problem goes away when using pixelRatio auto in render, but then I actually lose the limitations of the canvas and just zoom it in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant