Touch event on EmitterObject?

Hello,

EmitterObject is somewhat different than displayObject.

I cannot simply add touch event on it and control it.

add it to a group and then add event listener on the group doesn’t work either.

I tried to use a transparent (extreme low alpha) display object, and add listener on it.

This works but if the alpha is smaller then 0.004, it can not receive touch event though.

I want to ask if there is better solutions to add touch event on EmitterObject?

Thanks a lot!

Hi @hydralisk_mk2,

As you noticed, the emitter itself won’t receive a touch event. Your approach of adding an invisible display object over the emitter is the best choice, but you’ll need to set its “.isHitTestable” property to true so it can register touch/tap events. In that way, simply set the object to invisible (.isVisible=false instead of setting alpha to ~0) and this property will make sure the object receives touch/tap events.

https://docs.coronalabs.com/api/type/DisplayObject/isHitTestable.html

Best regards,

Brent

This works perfectly.

Thanks bunches!

Hi @hydralisk_mk2,

As you noticed, the emitter itself won’t receive a touch event. Your approach of adding an invisible display object over the emitter is the best choice, but you’ll need to set its “.isHitTestable” property to true so it can register touch/tap events. In that way, simply set the object to invisible (.isVisible=false instead of setting alpha to ~0) and this property will make sure the object receives touch/tap events.

https://docs.coronalabs.com/api/type/DisplayObject/isHitTestable.html

Best regards,

Brent

This works perfectly.

Thanks bunches!