dominate Posted January 13, 2016 Share Posted January 13, 2016 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? Thanks. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2016 Share Posted January 13, 2016 Make second sprite interactive too, but do nothing on click. Quote Link to comment Share on other sites More sharing options...
dominate Posted January 13, 2016 Author Share Posted January 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2016 Share Posted January 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
dominate Posted January 13, 2016 Author Share Posted January 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2016 Share Posted January 13, 2016 Yes, that's how it works right now. May be it will be reworked in v4. Quote Link to comment Share on other sites More sharing options...
dominate Posted January 13, 2016 Author Share Posted January 13, 2016 Ok. Thank you for your help. 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.