Filtering mouse input events

ciolaamotore

  • Posts: 17
If I have two actor, one on the top of the other in the scene, and those two have behaviors checking always if the mouse is over them, passing the mouse over both will cause to trigger the event twice. What can I do in order to have just the front most actor react to the mouse event?

kehwar

  • Posts: 75
You can't, mmm, you can make a scene behavior to keep the "current moused over" actor, and have the mouse behavior check if there is a "current moused over" actor in the scene

captaincomic

  • *
  • Posts: 6108
You could introduce a delay after each mouse event. Whenerver the mouse is pressed, set a boolean attribute "Wait" to true, then create a "Do after _ seconds" and after say 0.1 seconds set "Wait" to false again. Now only check for mouse press if "Wait" is false.
Thats what I do right now. It will prevent rapid mouse clicks in general and I guess it should also work for your case.

« Last Edit: November 18, 2011, 08:09:02 am by captaincomic »

ciolaamotore

  • Posts: 17
@captaincomic: it won't work, I do not need to filter rapid mouse clicks, I need to filter an event that occours twice when the mouse is simply *over* two superimposed actors.
@kehwar how can I detect the "current moused over" actor when all the superimposed actors trigger that event?

How come do all actors fire at the same time?

rob1221

  • *
  • Posts: 9472
Is there a reason you can't have only one actor trigger the event if they're on top of each other anyway?  Just remove the behavior from one actor?

ciolaamotore

  • Posts: 17
In my game it is supposed to have multiple actor which are objects and the player can drag them around, making them superimposed

kehwar

  • Posts: 75
Here you go... also in forge under Mouse Over Manager

Edit: Pic of example of use in actor

« Last Edit: November 18, 2011, 09:57:37 am by kehwar »

ciolaamotore

  • Posts: 17
@kehwar thanks for the post but I see that you loop through an Actor group, I need to loop through all actors and I wasn't able to do so (*). How can I do that?

(*) take a look at here http://community.stencyl.com/index.php/topic,4887.new.html#new

kehwar

  • Posts: 75
As far as i know, you can't cycle through all actor in scene, just edit the behavior and copy the [for each member of ] as many times you need

ciolaamotore

  • Posts: 17
I know, thanks for the effort, but as told in the other thread, I should use the scene behavior for different scenes and different actor groups, this appears like bad design to me. Even though I recognize that this is the only choice....

captaincomic

  • *
  • Posts: 6108
Ah, ok, I thought you wanted to create an event when you click the mouse while the mouse is over the actors.

To cycle through all actors, would it be possible to create a region that covers the whole scene, and then use the "for each actor inside region _" block?

kehwar

  • Posts: 75
There is another way, more flexible but will require a little more work... first, i would like to ask, why are there "different" groups in each scene?... from the other post i believe you only want to show a tooltip right? your problem being that when 2 actors are on top of each other the tooltip behaves wrong or maybe draw twice

If it were me, i'd create a tooltip behavior... to avoid it being draw twice i could make a global or scene attribute to check if the tooltip is being shown and validate to not draw it

Also, a workaround to get "all" the actors in the scene, you could make a scene-wide region, since there is a "for each actor inside region"what @captaincomic said

ciolaamotore

  • Posts: 17
If it were me, i'd create a tooltip behavior... to avoid it being draw twice i could make a global or scene attribute to check if the tooltip is being shown and validate to not draw it


The problem is that not the front most actor could have triggered the tooltip