FlxG.touches only registers one justPressed

71 views
Skip to first unread message

Andrew Grothe

unread,
Feb 2, 2016, 9:22:08 PM2/2/16
to HaxeFlixel
I have a jump counter in my jump() method to allow a double jump. This works great on keys.anyJustPressed and mouse.justPressed but the touch.justPressed only ever registers one tap.  I tried a boolean to ensure only one tap per update is registered and that made no difference.  Building and running on my Android just won't allow the double jump.


if (FlxG.keys.anyJustPressed(["SPACE"])) {
 jump
();
}


if (FlxG.mouse.justPressed) {
 jump
();
}


for (touch in FlxG.touches.list)
{
 
if (touch.justPressed)
 
{
 jump
();
 
}
}

I read about an issue in OpenFl but I'm running the latest version so hopefully that still isn't an issue.

actuate: [1.8.6]
box2d: [1.2.3]
flixel-addons: [1.1.1]
flixel-demos: [1.1.2]
flixel-templates: [1.0.2]
flixel-tools: [1.1.2]
flixel-ui: [1.0.2]
flixel: [3.3.12]
hxcpp: [3.2.205]
layout: [1.2.1]
lime-samples: [2.6.0]
lime: [2.9.0]
nape: [2.0.19]
openfl-samples: [3.3.1]
openfl: [3.6.0]
swf: [2.2.0]

Any ideas?

Andrew Grothe

unread,
Feb 3, 2016, 8:49:31 PM2/3/16
to HaxeFlixel
I got it sorted. Mobile devices pick up both mouse and touch events, so need to ensure conditional statements are used to only have one being used.

Gama11

unread,
Feb 5, 2016, 12:00:50 PM2/5/16
to HaxeFlixel
Yes, OpenFL fires mouse events for the first touch. This means you can just ignore touch input logic alltogether unless you specifically want to support multitouch. 
Reply all
Reply to author
Forward
0 new messages