Invisible Clickable Hotspots

Hello! I'm back making another ZIM game after a long time away, and it's great!

I have defined a blob area that I'd like to be clickable like an Image Map. When I set the alpha to zero the area stops handling clicks. Is there a workaround to make blobs invisible and clickable, please?

Hi @Chris_S welcome back - we missed you.

ZIM has clear and faint as colors. The clear is invisible and can't be clicked on. The faint is alpha .01 which is the lowest alpha that can be clicked on - so you can use that - it will probably do. You can also use the expand() method but that will use the bounding box - rectangle. It allows you to click invisible stuff as it applies a createjs hitArea. For the expand, it will automatically add 20 pixels but set the first parameter to 0 to not expand beyond the bounding box.

2 Likes

Thanks for your input @abstract, I had tried setting the opacity to 1% but the areas were showing up faintly as it was hard to match the blob colors to the varying background.

Instead I've decided to make my hit areas circles and use Pythagoras to determine whether the click coordinates are within each circle. It has the added benefit of significantly reducing the number of click listeners to one and simplifying the hit tests compared with my original complex blob shapes.

1 Like

Not 1%, not .1% but .01% - not sure if that is what you meant. It does show slightly but often you can't see it - especially if there is a border.

That sounds like a good solution. We have hitTestCircles that does a calculation between two circles but just realized a hitTestCirclePoint(x,y) could be handy to calculate a point in a circle. And I guess hitTestRectPoint(). Will add them to Requests and dwell...

An opacity of 0.01 is one hundredth of 1, i.e. 1%, isn't it?

Oh - I see - yes.