Exemple #1
0
 @Override
 public boolean keyUp(int keycode) {
   if (keycode == Keys.LEFT) controller.leftReleased();
   if (keycode == Keys.RIGHT) controller.rightReleased();
   if (keycode == Keys.Z) controller.jumpReleased();
   if (keycode == Keys.X) controller.fireReleased();
   return true;
 }
Exemple #2
0
 @Override
 public boolean touchDown(int screenX, int screenY, int pointer, int button) {
   if (!Gdx.app.getType().equals(ApplicationType.Android)) return false;
   if (screenX < width / 2 && screenY > height / 2) controller.leftPressed();
   if (screenX > width / 2 && screenY > height / 2) controller.rightPressed();
   if (screenX < width / 2 && screenY < height / 2) controller.jumpPressed(); // top left
   // if (screenX > width /2 && screenY < height /2) controller.firePressed(); // top right
   if (screenX > width / 2 && screenY < height / 2) controller.jumpPressed(); // top right
   return true;
 }
Exemple #3
0
  @Override
  public boolean keyDown(int keycode) {
    if (keycode == Keys.LEFT) controller.leftPressed();
    if (keycode == Keys.RIGHT) controller.rightPressed();
    if (keycode == Keys.Z) controller.jumpPressed();
    if (keycode == Keys.X) controller.firePressed();
    if (keycode == Keys.D) renderer.toggleDebug();

    return true;
  }
Exemple #4
0
 @Override
 public void render(float delta) {
   Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
   Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
   controller.update(delta);
   renderer.render();
 }
Exemple #5
0
  @Override
  public boolean touchDragged(int screenX, int screenY, int pointer) {
    if (!Gdx.app.getType().equals(ApplicationType.Android)) return false;

    // fix for dragging past the touch zones
    if (screenX < width / 2 && screenY < height / 2) controller.leftReleased();
    if (screenX > width / 2 && screenY < height / 2) controller.rightReleased();
    if (screenX > width / 2 && screenY > height / 2) {
      controller.leftReleased();
      controller.rightPressed();
    }
    if (screenX < width / 2 && screenY > height / 2) {
      controller.rightReleased();
      controller.leftPressed();
    }
    return true;
  }