Пример #1
0
  /**
   * Event handler so FlxGame can toggle keys.
   *
   * @param FlashEvent A <code>KeyboardEvent</code> object.
   */
  public void handleKeyUp(KeyboardEvent FlashEvent) {
    KeyState object = _map.get(FlashEvent.keyCode);

    if (object == null) return;
    if (object.current > 0) object.current = -1;
    else object.current = 0;

    try {
      ClassReflection.getField(Keyboard.class, object.name).set(this, false);
    } catch (Exception e) {
      FlxG.log("Keyboard", e.getMessage());
    }
  }
Пример #2
0
  /**
   * Event handler so FlxGame can toggle keys.
   *
   * @param FlashEvent A <code>KeyboardEvent</code> object.
   */
  public void handleKeyDown(KeyboardEvent FlashEvent) {
    KeyState object = _map.get(FlashEvent.keyCode);

    if (object == null) return;
    if (object.current > 0) object.current = 1;
    else object.current = 2;

    try { // TODO: Reflection is fairly slow, could we use a BooleanMap instead?
      ClassReflection.getField(Keyboard.class, object.name).set(this, true);
    } catch (Exception e) {
      FlxG.log("Keyboard", e.getMessage());
    }
  }