charlie_says Posted July 22, 2020 Share Posted July 22, 2020 This is going to sound a bit silly... I've got two sprites; one has a mouseclick event listener, the other has a mouseover event listener. The second sprite (mouseover) has to be under the first (mouseclick) but, I *really* want the mouseover event to still fire. Is this possible? (I've got another sprite under the first, which also has a mouseclick event listener, and on click, they will both fire, but the mouseover I'm having less luck with!) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 22, 2020 Share Posted July 22, 2020 (edited) Yes, you have to hack InteractionManager, and possibly its search object (TreeSearch). something like "renderer.plugins.interaction.search = new MySearch()". You have to look in the source code of interaction manager. However, mouseover is a very tricky thing, and I never did see how people did multiple over-s that are not parents to each other. If you do that thing - please share it. Edited July 22, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Jammy Posted July 22, 2020 Share Posted July 22, 2020 (edited) Hi, Potential workaround: Check if mouseclick is being fired for the one underneath, then clone the mouseover code into there? Edit: I have achieved this actually... When you click the sprite you want to drag, set its alpha to 0 and leave it where it is, create a replica of that sprite with a hitArea= rect(0,0,0,0) and use that to follow your mouse. Now when you move it over the other sprite, the pointerOver event should still fire. If you then drop the mouse-sprite, just destroy the original sprite, or move it to the new location and destroy the mouse sprite. Or if its a failed movement (i.e. they dropped it in a bad place) simple destroy the mouse sprite, and set alpha back to 1 on the original. Free-rollback! So whatever your application is, there may be potential for creating a ghost copy or setting the hitArea's to 0 temporarily to get the desired results. It's buggy at first but can be nailed eventually. Edited July 23, 2020 by Jammy Quote Link to comment Share on other sites More sharing options...
jonforum Posted July 23, 2020 Share Posted July 23, 2020 (edited) hard to say without code and demo, you sure you juste not forget to ```js e.stopPropagation(); e.preventDefault(); ``` somewhere Edited July 23, 2020 by jonforum Quote Link to comment Share on other sites More sharing options...
charlie_says Posted July 23, 2020 Author Share Posted July 23, 2020 Thanks both - when I looked again I realised my click wasn't actually working in the way I'd described... I think this is such an odd use case that actually trying to rework PIXI is not the correct approach... 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.