Question

I have an image which has some transparent areas. It is displayed multiple times and overlaps (with other instances of it).
The user should be able to click on underlaying instances of the image by clicking on transparent areas of the overlaying instances.

I tried to do this by using

this.addEventListener(TouchEvent.TOUCH, onTouch);
protected function onTouch(event:TouchEvent):void {
if (event.getTouch(this, TouchPhase.BEGAN))
{
    var touch:Touch = event.getTouch(this, TouchPhase.BEGAN);
    var image:Image = event.touches[0].target as Image;
}

But this approach does not seem to differ between transparent and non-transparent areas.

I've read that it should be possible to overwrite the Image-class of flash to store alpha-values, but I wasn't able to find a working example. And maybe there's a solution build-in in starling?

Était-ce utile?

La solution

You might try this solution. It seams it handles the same problem that you are having.

http://aphall.com/2012/12/starling-transparent-textures/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top