Jump to content

Event pass through overlapped sibling sprite


ChenXin
 Share

Recommended Posts

I have two overlapped sibling sprites, and they are NOT nested.

const spriteA = PIXI.Sprite.from(...)
app.stage.addChild(spriteA)
spriteA.interactive = true
spriteA.on("pointerdown", () => {console.log("spriteA")})

const spriteB = PIXI.Sprite.from(...)
app.stage.addChild(spriteB)
spriteB.interactive = true
spriteB.on("pointerdown", () => {console.log("spriteB")})

What I want to achieve:

When I click the overlapped area, I want the event on both spriteA and spriteB fired.

I leave spriteA and spriteB NOT nested on purpose, due to some reason they cannot be nested.

Screen Shot 2019-11-27 at 5.40.48 PM.png

Edited by ChenXin
Link to comment
Share on other sites

This behaviour is not included in pixi package. However, PixiJS team certainly does not have enough exp to implement everything that user wants. Since v5.2.0, you can override interaction behaviour.

Its possible by overriding TreeSearch. https://github.com/pixijs/pixi.js/tree/dev/packages/interaction/src

 "renderer.plugins.interaction.search = new MyTreeSearch();" should solve that, if you code that MyTreeSearch :)

Please share your results, I'll put your version in wiki as a hack: https://github.com/pixijs/pixi.js/wiki/v5-Hacks

Edited by ivan.popelyshev
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...