示例#1
0
  protected void input(Layer layer) {
    float current = accel * getFric();

    if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
      right = false;
      addXSpeed(-current * GameTime.deltaTime());
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
      right = true;
      addXSpeed(+current * GameTime.deltaTime());
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_UP) & canJump(layer)) {
      setYSpeed(-jumpForce / mass);
    }

    if (Math.abs(getXSpeed()) < 1) {
      move = 0;
    }
  }
示例#2
0
 public void onEvent(String event) {
   if (event.equals("Fly")) {
     addYMoment(-50 * GameTime.deltaTime());
   }
 }