Touch support for Windows

43 views
Skip to first unread message

Bink

unread,
Apr 20, 2016, 12:24:02 AM4/20/16
to HaxeFlixel


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

Gama11

unread,
Apr 20, 2016, 2:18:31 PM4/20/16
to HaxeFlixel
To my knowledge, OpenFL does not implement touch input on Windows. It should work in Flash though.

Bink

unread,
Apr 20, 2016, 5:46:48 PM4/20/16
to HaxeFlixel
That seems to be the case.  

With OpenFL however, I can get by using a MOUSE_DOWN event for single touch.  

However, the equivalent in HaxeFlixel, which if I'm not mistaken, is FlxG.mouse.justPressed, does not work the same way.  This property isn't true until I've both touched and dragged, which won't fire if the user simply taps the screen.

Ashiq A.

unread,
Apr 20, 2016, 5:48:17 PM4/20/16
to haxef...@googlegroups.com
I think you can use MouseDown/MouseUp event handlers to get what you want.

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at https://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/00cae3d9-e2f0-47eb-8e02-650c56bdf0d7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages