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

Adjusting Scale Breaks Click Events #8804

Closed
ColinF1977 opened this issue Oct 31, 2022 · 2 comments · Fixed by #8825
Closed

Adjusting Scale Breaks Click Events #8804

ColinF1977 opened this issue Oct 31, 2022 · 2 comments · Fixed by #8825

Comments

@ColinF1977
Copy link

Expected Behavior

When you adjust the renderer resolution click events on sprite should still work when you click the sprite

Current Behavior

When you adjust the renderer resolution click events fire when you click the possition the sprite would be if the resolution was 1

Possible Solution

?

Steps to Reproduce

Create a PIXI App
set the
renderer.resolution = 0.5

Add a sprite to stage
Add click event on sprite
Click sprite - Event does not fire
Click where sprite would be at 100% resolution - Event Fires

Environment

  • pixi.js version: 6.5.8
  • Browser & Version: Chrome 107
  • OS & Version: Windows 10
  • Running Example:
const app = new PIXI.Application();
document.body.appendChild(app.view);
app.renderer.resolution = 0.5

let bol = false;

// create a texture from an image path
const texture = PIXI.Texture.from('examples/assets/flowerTop.png');

// create a second texture
const secondTexture = PIXI.Texture.from('examples/assets/eggHead.png');

// create a new Sprite using the texture
const dude = new PIXI.Sprite(texture);

// center the sprites anchor point
dude.anchor.set(0.5);

// move the sprite to the center of the screen
dude.x = app.screen.width / 2;
dude.y = app.screen.height / 2;

app.stage.addChild(dude);

// make the sprite interactive
dude.interactive = true;
dude.buttonMode = true;

dude.on('pointertap', () => {
    bol = !bol;
    if (bol) {
        dude.texture = secondTexture;
    } else {
        dude.texture = texture;
    }
});

app.ticker.add(() => {
    // just for fun, let's rotate mr rabbit a little
    dude.rotation += 0.1;
});

@bigtimebuddy
Copy link
Member

Try setting the resolution in the Application constructor:
https://pixiplayground.com/#/edit/V_4cnlia5EfUb8P-ReuCP

@nw-b
Copy link
Contributor

nw-b commented Nov 3, 2022

Used to be able to set the resolution of the old InteractionManager - something I was doing along with setting the renderer's resolution upon resize, to detect changes to the viewport size as well as the page being zoomed in and the devicePixelRatio changing.

Just figured out I can set app.renderer._view.resolution to get back the ability to change the resolution on the fly, but no way to do so for the new events system unfortunately.

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

Successfully merging a pull request may close this issue.

3 participants