Need help making invisible buttons

Hey All!

I am trying to create invisible buttons( or triggers or sensors) and need some help.

I have a background image which includes “baked in” button images, and to save on RAM,
I want to make invisible buttons or sensors that sit on top of the image to act as the hit areas.

The buttons are all rotated at different angles.

So to accomplish this, I have created a bunch of rotated rectangles and placed them in the appropriate
positions.

I added event listeners to each of them.

This all works fine. However, when I set the alpha of the rectangles to 0, they no longer work.
They will work if I set the alpha to 0.1-1

Is there a flag I can set on the rectangles to still capture events when their alpha is 0?

Or an easier/better way to accomplish this?

Thanks!
Joe

[import]uid: 8444 topic_id: 3201 reply_id: 303201[/import]

Why don’t you just move the rectangles (the listener containers) bellow the background image? They will be invisible but the tap listeners will be active. Just don’t swallow (return true) your taps in possible background tap handlers.

[import]uid: 7356 topic_id: 3201 reply_id: 9435[/import]

ha. yes that is actually what I did! I just wanted to know if there was a parameter I was missing. [import]uid: 8444 topic_id: 3201 reply_id: 9447[/import]

Don’t give the rectangle a color, then it is invisible. [import]uid: 5712 topic_id: 3201 reply_id: 9470[/import]

Ah, ok. Good to know.
But an invisible (alpha = 0) Display Object cannot register events, correct?

I guess I could also load in a 1x1 pixel transparent .png and use that to create hit areas.

EDIT: Just found this API: object.isHitTestable
That is what I was looking for! [import]uid: 8444 topic_id: 3201 reply_id: 9474[/import]