Jump to content

Adjusting Resolution screws up ClickEvents Position


GV Guy
 Share

Recommended Posts

I've run into an issue with using click events with an adjusted resolution

The event seems to trigger when you click where the sprite would be at 1.0 resolution rather than where the sprite actually is.

I've reproduced using the examples here:

https://pixijs.io/examples/#/sprite/texture-swap.js

 

If I add the line:

app.renderer.resolution = 0.5

 

Then the stage is shrunk to 50% size, but the click event is triggered when I click the middle of the canvas and not the actual sprite.

Am I doing something wrong?

 

 

 

Link to comment
Share on other sites

  • 4 months later...

I added the line you said right in the beginning like this

const app = new PIXI.Application({ background: '#1099bb' });
document.body.appendChild(app.view);
app.renderer.resolution = 0.5

And it worked like it should, the mouse is detected on the sprite and not on the centre of the canvas. Are you sure you did not change anything else?

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...