Jump to content

mouseover event on 'covered' sprite


charlie_says
 Share

Recommended Posts

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!)

Link to comment
Share on other sites

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 by ivan.popelyshev
Link to comment
Share on other sites

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 by Jammy
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...