-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1b6d07
commit 00a19a7
Showing
8 changed files
with
572 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package flixel.input; | ||
|
||
import raylib.KeyboardKey; | ||
|
||
class FlxBaseKeyList { | ||
|
||
public var state(default, null):FlxInputState; | ||
|
||
public function new(state:FlxInputState) { | ||
this.state = state; | ||
} | ||
|
||
public function check(key:KeyboardKey):Bool { | ||
switch (this.state) { | ||
case JUST_RELEASED: | ||
return isKeyReleased(key); | ||
case RELEASED: | ||
return !isKeyDown(key); | ||
case PRESSED: | ||
return isKeyDown(key); | ||
case JUST_PRESSED: | ||
return isKeyPressed(key); | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package flixel.input; | ||
|
||
enum abstract FlxInputState(Int) from Int { | ||
var JUST_RELEASED:Int = -1; | ||
var RELEASED:Int = 0; | ||
var PRESSED:Int = 1; | ||
var JUST_PRESSED:Int = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package flixel.input; | ||
|
||
import flixel.input.keyboard.FlxKeyList; | ||
|
||
class FlxKeyManager { | ||
public var pressed(default, null):FlxKeyList; | ||
|
||
public var justPressed(default, null):FlxKeyList; | ||
|
||
public var released(default, null):FlxKeyList; | ||
|
||
public var justReleased(default, null):FlxKeyList; | ||
|
||
public function new() { | ||
pressed = new FlxKeyList(PRESSED); | ||
justPressed = new FlxKeyList(JUST_PRESSED); | ||
released = new FlxKeyList(RELEASED); | ||
justReleased = new FlxKeyList(JUST_RELEASED); | ||
} | ||
} |
Oops, something went wrong.