I have a Starling Sprite
which I want to get touch events for. A am using
content.addEventListener(TouchEvent.TOUCH, onTouch);
function onTouch(e:TouchEvent) {
var touch:Touch = e.getTouch(content) as Touch;
if (touch) {
//do something
}
}
However, this is only working when the children of the Sprite are touched and not on the space in between them. I am thinking that if I create an alpha'd Image and stick underneath it should then pick up the touch events, but is there a better way?
I was also thinking about listening for the touch on the stage and doing the equivalent of a hitTestPoint()
.
I came up with
var hitTest = (touch && content.hitTest(this.globalToLocal(new Point(touch.globalX, touch.globalY))));
But this doesn't seem to work either, the touch event is only working when a child of the content Sprite is touched.
Solution:
In the end I used an alpha'd Quad as suggested by Cherniv
bg = new Quad(width, height);
bg.alpha = 0;
addChildAt(bg, 0);
isTouching()
: doc.starling-framework.org/core/starling/events/… ? – Quickwitted