Disregard Transparency When Mouse Hovers Over Actor

Epic428

  • Posts: 1118
Is there any way to disregard transparency when the mouse is hovering over an actor?

I ask this, because I needed to add a decently sized transparent border to some of my button images so that the look created in Photoshop stayed the same in the game. Because the transparency is not ignored, it can create problems for code that is run when the mouse is hovering over or clicking on the actor.

Such problems could be: a hover animation might play if the mouse is near the button, but not actually "on" the button, somewhat overlapping buttons could cause conflicts in the code, etc.

I know that buttons created in flash under the class SimpleButton are given a Hit Box field to specify what parts of the button should react to the mouse.  I'm not sure how something similar to this would translate into stencyl, or what subsequent code could be used to ignore the transparency.

Any ideas on how to solve this would be great.

I'm not sure of what side effects there would be, but perhaps making this engine side would be a plausible solution too?
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Hectate

  • *
  • Posts: 4645
I was under the impression that the mouse only registered hits on the collision box - which could be adjusted for the button actor to accomodate the excess transparency.

If that's not the case, you can create a false mouse cursor actor that is a sensor for detecting that ajdusted button collision shape instead. Just always set it's X,Y to the mouse's X,Y (plus/minus any offset needed).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Epic428

  • Posts: 1118
The mouse doesn't register hits on the collision box. Usually I try to remove collision boxes on all actors that don't need them to increase the frame rate.

I like that idea, and looking around in SW I thought that maybe checking the mouse's x/y coordinates would work as well? Though, I'm not sure which would be better or if there would be another ideal solution?
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Hectate

  • *
  • Posts: 4645
Checking the mouse's  coords would work, although it sounds like more effort because it would require you to do the math for the appropriate settings. You'd have to simultaneously check if the mouse's location was both More Than the appropriate offset value of the button AND Less Than the offset Plus button width - and do it for both X and Y. Once all 4 conditions are saying "TRUE", you SHOULD BE hovering over the button and THEN can check if the mouse is pressed, etc.

Using the actor-as-cursor method (with the normal one hidden) allows you to both check it easily (using the a new collision group and existing collision/sensor blocks) and also update the cursor easily (animating it, for example) when those conditions are met. It's more flexible and much simpler, and the sensors shouldn't add much overhead to the game's performance.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Epic428

  • Posts: 1118
Yeah, I can see the difference there. For now I will use the sensor and check the collisions.

I still think a proper solution would be to do this engine side, but again, I'm not sure what, if any, negative side effects would be caused.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs