How to compare Key in an array with FlxKeyList?
-
Purpose:
- Comparing the stored keys (from an array),
- Trying to implement FSM Combo Moves
Snippet:
Root of the problem, trying to check whether the first element is "H pressed" or not.
var record = FlxG.keys.getIsDown(); if (record.length == 0 || record[0].ID != FlxKeyList.H){ this.comboHit = 0; }
Returned:
Class<flixel.input.FlxKeyManager> has no field H
-
I think the keys are in
FlxKey
likeFlxKey.H
-
Ah, I see. You're right.
Thanks.
I was confused with
FlxKeyList
: http://api.haxeflixel.com/flixel/input/keyboard/FlxKeyList.html#H andFlxKey
.I thought
FlxKeyList
was the right one to be used, since IF is also Boolean.
-
FlxKeyList
is just a list of flags likeFlxG.keys.pressed
. When you call a key from it likeFlxG.keys.pressed.H
, you'll get a Boolean whether the key is pressed or not.