com.badlogic.gdx.Input.isButtonPressed()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.badlogic.gdx.Input.isButtonPressed()方法的一些代码示例,展示了Input.isButtonPressed()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.isButtonPressed()方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:isButtonPressed

Input.isButtonPressed介绍

[英]Whether a given button is pressed or not. Button constants can be found in Buttons. On Android only the Buttons#LEFT constant is meaningful before version 4.0.
[中]是否按下给定按钮。按钮常量可以在按钮中找到。在Android上,在4.0版本之前,只有按钮#LEFT常量有意义。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public boolean isButtonPressed (int button) {
  return input.isButtonPressed(button);
}

代码示例来源:origin: libgdx/libgdx

static public boolean left () {
  return Gdx.input.isButtonPressed(Buttons.LEFT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean right () {
  return Gdx.input.isButtonPressed(Buttons.RIGHT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean middle () {
  return Gdx.input.isButtonPressed(Buttons.MIDDLE);
}

代码示例来源:origin: libgdx/libgdx

static public boolean middle () {
  return Gdx.input.isButtonPressed(Buttons.MIDDLE);
}

代码示例来源:origin: libgdx/libgdx

static public boolean right () {
  return Gdx.input.isButtonPressed(Buttons.RIGHT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean middle () {
  return Gdx.input.isButtonPressed(Buttons.MIDDLE);
}

代码示例来源:origin: libgdx/libgdx

static public boolean left () {
  return Gdx.input.isButtonPressed(Buttons.LEFT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean right () {
  return Gdx.input.isButtonPressed(Buttons.RIGHT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean left () {
  return Gdx.input.isButtonPressed(Buttons.LEFT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean left () {
  return Gdx.input.isButtonPressed(Buttons.LEFT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean right () {
  return Gdx.input.isButtonPressed(Buttons.RIGHT);
}

代码示例来源:origin: libgdx/libgdx

static public boolean middle () {
  return Gdx.input.isButtonPressed(Buttons.MIDDLE);
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void render () {
    if (Gdx.input.justTouched()) {
      Gdx.app.log("Input Test", "just touched, button: " + (Gdx.input.isButtonPressed(Buttons.LEFT) ? "left " : "")
        + (Gdx.input.isButtonPressed(Buttons.MIDDLE) ? "middle " : "")
        + (Gdx.input.isButtonPressed(Buttons.RIGHT) ? "right" : "")
        + (Gdx.input.isButtonPressed(Buttons.BACK) ? "back" : "")
        + (Gdx.input.isButtonPressed(Buttons.FORWARD) ? "forward" : ""));
    }

    for (int i = 0; i < 10; i++) {
      if (Gdx.input.getDeltaX(i) != 0 || Gdx.input.getDeltaY(i) != 0) {
        Gdx.app.log("Input Test", "delta[" + i + "]: " + Gdx.input.getDeltaX(i) + ", " + Gdx.input.getDeltaY(i));
      }
    }
// Gdx.input.setCursorPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
// if(Gdx.input.isTouched()) {
// Gdx.app.log("Input Test", "is touched");
// }
  }

代码示例来源:origin: libgdx/libgdx

public boolean touchDown (int x, int y, int pointer, int newParam) {
  if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
    Vector3 touchPoint = new Vector3(x, y, 0);
    worldCamera.unproject(touchPoint);
    effect.setPosition(touchPoint.x, touchPoint.y);
  }
  return false;
}

代码示例来源:origin: libgdx/libgdx

public boolean touchDragged (int x, int y, int pointer) {
  if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
    Vector3 touchPoint = new Vector3(x, y, 0);
    worldCamera.unproject(touchPoint);
    effect.setPosition(touchPoint.x, touchPoint.y);
  }
  return false;
}

代码示例来源:origin: libgdx/libgdx

public boolean touchDragged (int x, int y, int pointer) {
  if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
    Vector3 touchPoint = new Vector3(x, y, 0);
    worldCamera.unproject(touchPoint);
    effect.setPosition(touchPoint.x, touchPoint.y);
  }
  return false;
}

代码示例来源:origin: libgdx/libgdx

public boolean touchDown (int x, int y, int pointer, int newParam) {
  if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
    Vector3 touchPoint = new Vector3(x, y, 0);
    worldCamera.unproject(touchPoint);
    effect.setPosition(touchPoint.x, touchPoint.y);
  }
  return false;
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  angle += Gdx.graphics.getDeltaTime() * 45;
  matrix.setToRotation(axis, angle);
  
  Mesh meshToDraw = Gdx.input.isButtonPressed(0) ? meshCustomVA : mesh;
  Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl20.glClearColor(0.2f, 0.2f, 0.2f, 1);
  Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
  Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D);
  Gdx.gl20.glEnable(GL20.GL_BLEND);
  Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
  texture.bind();
  shader.begin();
  shader.setUniformMatrix("u_worldView", matrix);
  shader.setUniformi("u_texture", 0);
  meshToDraw.render(shader, GL20.GL_TRIANGLES);
  shader.end();
}

代码示例来源:origin: mbrlabs/Mundus

private BrushAction getAction() {
  final boolean primary = Gdx.input.isButtonPressed(BrushAction.PRIMARY.code);
  final boolean secondary = Gdx.input.isKeyPressed(BrushAction.SECONDARY.code);
  if (primary && secondary) {
    return BrushAction.SECONDARY;
  } else if (primary) {
    return BrushAction.PRIMARY;
  }
  return null;
}

相关文章