Mouse Events on Collision Shape

gcarne

  • Posts: 111
I want to reduce the clickable area of an actor to avoid the problem of overlapping actors. There is a behavior in Stencyl Forge for this (see attached image) called Mouse Events on Collision Shapes , but downloading generates an error. Is this behavior not longer available or is an active license required for the download?

Luyren

  • *
  • Posts: 2506
StencylForge has been discontinued for a while, all the behaviors that are still there are pretty old and not exactly reliable.

You can have a behavior that checks for the actor's image, and only detects non transparent pixels as valid for a mouse check on actor. Alternatively, create a system with scene/actor behaviors that gets all the actors that were clicked on, with a custom block that returns the actor in the top layer/highest Z-order, which ever is in front, to circumvent the overlap thing.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

gcarne

  • Posts: 111
The block "get pixel at. . ." can only be used for a color attribute, it does not pass values to text- or number-attributes which would have been useful.

How does one read/check this color attribute without writing code and pass it to a game attribute? In the attached example which is inside an actor behavior I always get "pixel has value" regardless of where on the actor I click, on the transparent part or not. Perhaps it is gets a value also from the background?

Luyren

  • *
  • Posts: 2506

This checks if the given pixel in the actor's image is not transparent (note the "not" block in there as well).

Meaning the get pixel block, and any color block for that matter, can be used as a number as well, or even converted to a text.

Also note that mouse coordinates are always in screen space, so you need to convert the mouse coordinates appropriately, depending on your game. If it is single screen you don't need to do anything. If you have camera movement, you need to add the camera position to the mouse position.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter