I've been wrestling with trying to get touch to work under Windows but I'm running into a number of problems.
Firstly, I've commented out this line from my
Project.xml file, to make touch available:
<!--haxedef name="FLX_NO_TOUCH" if="desktop" /-->
I'm able to establish a touch, but I can't get any coordinates from it, or use it with
touch.overlap(). I've done some digging and it would seem the touch coordinates are always 0,0. When I test a
TOUCH_BEGIN event with OpenFL, I get the same result so I suspect the issue stems from there.
However, in OpenFL, the
MOUSE_DOWN event fires even with a touch and coordinates can be pulled from that.
Unfortunately, HaxeFlixel's FlxG.mouse.justPressed does not fire with a touch. It will only fire if I touch and drag and seemingly not reliably.
Am I doing something wrong, or is this a known limitation?
public override function update(elapsed:Float):Void
{
for (touch in FlxG.touches.list)
{
if (touch.justPressed)
{
if (touch.overlaps(ball))
{
trace("Ball touched");
} else {
trace("Ball not touched");
}
}
}
if (FlxG.mouse.justPressed)
{
if (FlxG.mouse.overlaps(ball))
{
trace("Ball clicked");
} else {
trace("Ball not clicked");
}
}
super.update(elapsed);
}
Output when ball is clicked (mouse):
BallView.hx:58: Ball clicked
Output when ball is touched:
BallView.hx:49: Ball not touched