|
@@ -44,6 +44,9 @@ class Key {
|
|
public static inline var NUMPAD_DOT = 110;
|
|
public static inline var NUMPAD_DOT = 110;
|
|
public static inline var NUMPAD_DIV = 111;
|
|
public static inline var NUMPAD_DIV = 111;
|
|
|
|
|
|
|
|
+ public static inline var MOUSE_LEFT = 0;
|
|
|
|
+ public static inline var MOUSE_RIGHT = 1;
|
|
|
|
+
|
|
static var initDone = false;
|
|
static var initDone = false;
|
|
static var keyPressed : Array<Int> = [];
|
|
static var keyPressed : Array<Int> = [];
|
|
|
|
|
|
@@ -64,7 +67,7 @@ class Key {
|
|
dispose();
|
|
dispose();
|
|
initDone = true;
|
|
initDone = true;
|
|
keyPressed = [];
|
|
keyPressed = [];
|
|
- Stage.getInstance().addEventTarget(onKeyEvent);
|
|
|
|
|
|
+ Stage.getInstance().addEventTarget(onEvent);
|
|
#if flash
|
|
#if flash
|
|
flash.Lib.current.stage.addEventListener(flash.events.Event.DEACTIVATE, onDeactivate);
|
|
flash.Lib.current.stage.addEventListener(flash.events.Event.DEACTIVATE, onDeactivate);
|
|
#end
|
|
#end
|
|
@@ -72,7 +75,7 @@ class Key {
|
|
|
|
|
|
public static function dispose() {
|
|
public static function dispose() {
|
|
if( initDone ) {
|
|
if( initDone ) {
|
|
- Stage.getInstance().removeEventTarget(onKeyEvent);
|
|
|
|
|
|
+ Stage.getInstance().removeEventTarget(onEvent);
|
|
#if flash
|
|
#if flash
|
|
flash.Lib.current.stage.removeEventListener(flash.events.Event.DEACTIVATE, onDeactivate);
|
|
flash.Lib.current.stage.removeEventListener(flash.events.Event.DEACTIVATE, onDeactivate);
|
|
#end
|
|
#end
|
|
@@ -87,12 +90,16 @@ class Key {
|
|
}
|
|
}
|
|
#end
|
|
#end
|
|
|
|
|
|
- static function onKeyEvent( e : Event ) {
|
|
|
|
|
|
+ static function onEvent( e : Event ) {
|
|
switch( e.kind ) {
|
|
switch( e.kind ) {
|
|
case EKeyDown:
|
|
case EKeyDown:
|
|
keyPressed[e.keyCode] = h3d.Engine.getCurrent().frameCount+1;
|
|
keyPressed[e.keyCode] = h3d.Engine.getCurrent().frameCount+1;
|
|
case EKeyUp:
|
|
case EKeyUp:
|
|
keyPressed[e.keyCode] = -(h3d.Engine.getCurrent().frameCount+1);
|
|
keyPressed[e.keyCode] = -(h3d.Engine.getCurrent().frameCount+1);
|
|
|
|
+ case EPush:
|
|
|
|
+ keyPressed[e.button] = h3d.Engine.getCurrent().frameCount+1;
|
|
|
|
+ case ERelease:
|
|
|
|
+ keyPressed[e.button] = -(h3d.Engine.getCurrent().frameCount+1);
|
|
default:
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|