Jump to content

how to get rid of creating events of overlapped Sprite


Recommended Posts

I have some Sprites, which are put in a row so that one partially overlaps the previous one.

Some of them are interactive whereas some are not.

When I click on non-interactive Sprite, if on that point (under the clicked Sprite) there is the previous overlapped interactive Sprite, onclick event is generated for that Sprite.

What I want is to generate click event if and only if I click on the interactive Sprite.

How do I achieve this?



Link to comment
Share on other sites

20 minutes ago, ivan.popelyshev said:

Make second sprite interactive too, but do nothing on click.


But this is a bit "hacking". Then I would need to maintain such info like that "interactive but not so much, this is really truely interactive".. And imagine that later another overlapping Sprite comes. Then I should check if it overlaps any really truely interactive Sprite, and if there is, then make it "a little bit, falsely" interactive..

There should be some good practice in pixijs, since it is a common issue.

Link to comment
Share on other sites

16 minutes ago, ivan.popelyshev said:

Its not hacking. Look at how "pointer-events: none" works in CSS, thats what makes DOM elements not interactive. Not interactive means that element is completely ignored.

Imagine this scenario: Depending on the states, the Sprites can be interactive, or not; one overlapping the other, or the contrary, etc.

Then this means that by default I have to make all Sprites interactive, right? And then I should make myobj.off("click", ..), myobj.on("click",..) every time I need to make interactive or not. Right? (I dont consider checking in onclick method)

I had thought to use interactive true/false instead of making on-off every time.

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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...