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

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

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

Input.isTouched介绍

暂无

代码示例

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

@Override
public boolean isTouched () {
  return input.isTouched();
}

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

@Override
public boolean isTouched (int pointer) {
  return input.isTouched(pointer);
}

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

private boolean isTouched (float startX, float endX) {
  // Check for touch inputs between startX and endX
  // startX/endX are given between 0 (left edge of the screen) and 1 (right edge of the screen)
  for (int i = 0; i < 2; i++) {
    float x = Gdx.input.getX(i) / (float)Gdx.graphics.getWidth();
    if (Gdx.input.isTouched(i) && (x >= startX && x <= endX)) {
      return true;
    }
  }
  return false;
}

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

public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
  if (pointer != -1) return;
  if (Gdx.input.isTouched()) return;
  Actor actor = event.getListenerActor();
  if (fromActor != null && fromActor.isDescendantOf(actor)) return;
  setContainerPosition(actor, x, y);
  manager.enter(this);
}

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

public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
  if (pointer != -1) return;
  if (Gdx.input.isTouched()) return;
  Actor actor = event.getListenerActor();
  if (fromActor != null && fromActor.isDescendantOf(actor)) return;
  setContainerPosition(actor, x, y);
  manager.enter(this);
}

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

public void render () {
    // set the clear color and clear the screen.
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isTouched()) {
      Gdx.graphics.setCursor(cursor1);
    } else {
      cursorActive = !cursorActive;
      if (cursorActive) {
        Gdx.graphics.setCursor(cursor2);
      } else {
        Gdx.graphics.setCursor(cursor3);
      }
    }
  }
}

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

@Override
public void render () {
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  camera.update();
  renderer.setProjectionMatrix(camera.combined);
  if (Gdx.input.isTouched()) camera.unproject(globalCoords.set(Gdx.input.getX(), Gdx.input.getY(), 0));
  solveFakeIK(globalCoords);
  renderBones();
}

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

public void render () {
    // set the clear color and clear the screen.
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // draw the sprite
    batch.begin();
    batch.draw(texture, spritePosition.x, spritePosition.y);
    batch.end();

    // if a finger is down, set the sprite's x/y coordinate.
    if (Gdx.input.isTouched()) {
      // the unproject method takes a Vector3 in window coordinates (origin in
      // upper left corner, y-axis pointing down) and transforms it to world
      // coordinates.
      camera.unproject(spritePosition.set(Gdx.input.getX(), Gdx.input.getY(), 0));
    }
  }
}

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

@Override
public void render () {
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  camera.update();
  renderer.setProjectionMatrix(camera.combined);
  renderer.begin(ShapeType.Filled);
  int size = Math.max(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()) / 10;
  for (int i = 0; i < 10; i++) {
    if (!Gdx.input.isTouched(i)) continue;
    viewport.unproject(tp.set(Gdx.input.getX(i), Gdx.input.getY(i)));
    Color color = colors[i % colors.length];
    renderer.setColor(color);
    float sSize = size * Gdx.input.getPressure(i);
    renderer.triangle(tp.x, tp.y + sSize, tp.x + sSize, tp.y - sSize, tp.x - sSize, tp.y - sSize);
  }
  renderer.end();
}

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

gestureStartTime = Gdx.input.getCurrentEventTime();
tracker.start(x, y, gestureStartTime);
if (Gdx.input.isTouched(1)) {

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

gestureStartTime = Gdx.input.getCurrentEventTime();
tracker.start(x, y, gestureStartTime);
if (Gdx.input.isTouched(1)) {

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

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (Gdx.input.isTouched()) {
  stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY()));
  Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);

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

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.begin(ShapeType.Filled);
if (Gdx.input.isTouched())
  renderer.setColor(Color.RED);
else

代码示例来源:origin: BrentAureli/FlappyDemo

@Override
public void handleInput() {
  if(Gdx.input.isTouched()) {
    if(gameover)
      gsm.set(new PlayState(gsm));
    else
      bird.jump();
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
  if (pointer != -1) return;
  if (Gdx.input.isTouched()) return;
  Actor actor = event.getListenerActor();
  if (fromActor != null && fromActor.isDescendantOf(actor)) return;
  setContainerPosition(actor, x, y);
  manager.enter(this);
}

代码示例来源:origin: dsaltares/libgdx-cookbook

private void updateCamera() {
  direction.set(0.0f, 0.0f);
  int mouseX = Gdx.input.getX();
  int mouseY = Gdx.input.getY();
  int width = Gdx.graphics.getWidth();
  int height = Gdx.graphics.getHeight();
  if (Gdx.input.isKeyPressed(Keys.LEFT) || (Gdx.input.isTouched() && mouseX < width * 0.25f)) {
    direction.x = -1;
  }
  else if (Gdx.input.isKeyPressed(Keys.RIGHT) || (Gdx.input.isTouched() && mouseX > width * 0.75f)) {
    direction.x = 1;
  }
  if (Gdx.input.isKeyPressed(Keys.UP) || (Gdx.input.isTouched() && mouseY < height * 0.25f)) {
    direction.y = 1;
  }
  else if (Gdx.input.isKeyPressed(Keys.DOWN) || (Gdx.input.isTouched() && mouseY > height * 0.75f)) {
    direction.y = -1;
  }
  direction.nor().scl(CAMERA_SPEED * Gdx.graphics.getDeltaTime());;
  camera.position.x += direction.x;
  camera.position.y += direction.y;
  camera.update();
}

代码示例来源:origin: jmrapp1/SpaceInvaders

public void checkInput(OrthoCamera cam) { 
  if (Gdx.input.isTouched()) {
    int button = getButtonPressed();
    Vector2 pos = cam.unprojectCoordinates(Gdx.input.getX(), Gdx.input.getY());
    for (MouseListener l : listeners)
      if(l.onMousePressed(cam, pos.x, pos.y, button))
        break;
  }
}

代码示例来源:origin: dsaltares/libgdx-cookbook

int height = Gdx.graphics.getHeight();
if (Gdx.input.isKeyPressed(Keys.LEFT) || (Gdx.input.isTouched() && mouseX < width * 0.25f)) {
  direction.x = -1;
else if (Gdx.input.isKeyPressed(Keys.RIGHT) || (Gdx.input.isTouched() && mouseX > width * 0.75f)) {
  direction.x = 1;
if (Gdx.input.isKeyPressed(Keys.UP) || (Gdx.input.isTouched() && mouseY < height * 0.25f)) {
  direction.y = 1;
else if (Gdx.input.isKeyPressed(Keys.DOWN) || (Gdx.input.isTouched() && mouseY > height * 0.75f)) {
  direction.y = -1;

代码示例来源:origin: dsaltares/libgdx-cookbook

int height = Gdx.graphics.getHeight();
if (Gdx.input.isKeyPressed(Keys.LEFT) || (Gdx.input.isTouched() && mouseX < width * 0.25f)) {
  direction.x = -1;
else if (Gdx.input.isKeyPressed(Keys.RIGHT) || (Gdx.input.isTouched() && mouseX > width * 0.75f)) {
  direction.x = 1;
if (Gdx.input.isKeyPressed(Keys.UP) || (Gdx.input.isTouched() && mouseY < height * 0.25f)) {
  direction.y = 1;
else if (Gdx.input.isKeyPressed(Keys.DOWN) || (Gdx.input.isTouched() && mouseY > height * 0.75f)) {
  direction.y = -1;

代码示例来源:origin: konsoletyper/teavm-libgdx

@Override
public void update (float delta) {
  simulation.update(delta);
  float accelerometerY = Gdx.input.getAccelerometerY();
  if (accelerometerY < 0)
    simulation.moveShipLeft(delta, Math.abs(accelerometerY) / 10);
  else
    simulation.moveShipRight(delta, Math.abs(accelerometerY) / 10);
  if (invaders.getController() != null) {
    if (buttonsPressed > 0) {
      simulation.shot();
    }
    // if the left stick moved, move the ship
    float axisValue = invaders.getController().getAxis(Ouya.AXIS_LEFT_X) * 0.5f;
    if (Math.abs(axisValue) > 0.25f) {
      if (axisValue > 0) {
        simulation.moveShipRight(delta, axisValue);
      } else {
        simulation.moveShipLeft(delta, -axisValue);
      }
    }
  }
  if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT) || Gdx.input.isKeyPressed(Keys.A)) simulation.moveShipLeft(delta, 0.5f);
  if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT) || Gdx.input.isKeyPressed(Keys.D)) simulation.moveShipRight(delta, 0.5f);
  if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.SPACE)) simulation.shot();
}

相关文章