Is there a way to easily query JustPressed on a FlxButton?

63 views
Skip to first unread message

MegaLeon

unread,
Jan 7, 2016, 1:52:44 PM1/7/16
to haxef...@googlegroups.com
I have a virtualPad button and would like to trigger an event only on `justPressed`, not `pressed`.

Doing this for a keyboard button is quite straightforward since we have a dedicated event, `FlxG.keys.justPressed`

However I see no way to achieve this on a FlxButton, there's only `status == FlxButton.PRESSED`, alongside with `HIGHLIGHT` and `NORMAL`. Am I missing something?

I could loop through `FlxG.touches` and check if there's any overlapping ones with the button at `(touch.justPressed)` and fire the event myself. Isn't that happening already under the bonnet in FlxTypedButton however? How about adding a fourth status `JUSTPRESSED`?

EDIT: Was reading the old documentation, switched to dev and found out about the IflxInput getters.

I still have problems, though: `button.justPressed` fires only during swipes, AKA when start the touch outside the button and then swipe on the button without releasing the touch.

If I set `button.allowSwiping = false`, `button.justPressed` fires only if the button is touched AFTER another point in the screen is being touched, so only with 2 simultaneous touches on screen. 

Is this the correct behavior? Sounds like a bug to me...

MegaLeon

unread,
Jan 8, 2016, 1:12:27 PM1/8/16
to HaxeFlixel
Apparently this work when disabling the mouse with FLX_NO_MOUSE

Reply all
Reply to author
Forward
0 new messages