Minimog Posted July 17, 2020 Share Posted July 17, 2020 I made simple recreation available at Codesandbox In essence following code triggers alert function when I click on a text even though my interaction listener is set on the sprite. I was under impression that pixi handles this case (when element is covered by another), but I guess I was wrong. Is there a way to only fire interaction if I click on sprite explicitly and not on any element that is covering it? Code import * as PIXI from "pixi.js"; const application = new PIXI.Application({ resolution: window.devicePixelRatio, autoDensity: true, width: window.innerWidth / 1.2, height: window.innerHeight / 1.2, view: document.getElementById("app"), backgroundColor: 0x0000ff }); const sprite = PIXI.Sprite.from(PIXI.Texture.WHITE); sprite.width = window.innerWidth / 1.5; sprite.height = window.innerHeight / 1.5; sprite.interactive = true; sprite.addListener("pointertap", () => { alert("Click!"); }); const text = new PIXI.Text("Hello World"); text.style = { fontSize: window.innerWidth / 10 }; application.stage.addChild(sprite); application.stage.addChild(text); Quote Link to comment Share on other sites More sharing options...
Scipion Posted July 20, 2020 Share Posted July 20, 2020 I'm also interested in this. I tried to use the zIndex property and it didn't work. I applied to de app container sortableChildren true in order to make it work but it was unsuccessful too. app.stage.sortableChildren=true; Here you can take a look to the experiment: https://jsfiddle.net/hr04y9jz/ Quote Link to comment Share on other sites More sharing options...
Exca Posted August 3, 2020 Share Posted August 3, 2020 The covering element has to have interaction enabled as well as the other item. Only those that are marked as interactive and whose parents dont have interactivechildren are taken into account when checking interactions. Minimog 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.