本文整理了Java中com.badlogic.gdx.Input.getX()
方法的一些代码示例,展示了Input.getX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.getX()
方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:getX
暂无
代码示例来源:origin: libgdx/libgdx
@Override
public int getX () {
return input.getX();
}
代码示例来源:origin: libgdx/libgdx
@Override
public int getX (int pointer) {
return input.getX(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
@Override
public void render () {
currentPosition = music.getPosition();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(buttons, 0, 0);
font.draw(batch, (int)currentPosition / 60 + ":" + (int)currentPosition % 60, 365, 35);
batch.end();
sliderUpdating = true;
slider.setValue((currentPosition / songDuration) * 100f);
sliderUpdating = false;
stage.act();
stage.draw();
if (Gdx.input.justTouched()) {
if (Gdx.input.getY() > Gdx.graphics.getHeight() - 64) {
if (Gdx.input.getX() < 64) {
music.play();
}
if (Gdx.input.getX() > 64 && Gdx.input.getX() < 128) {
music.stop();
}
if (Gdx.input.getX() > 128 && Gdx.input.getX() < 192) {
music.pause();
}
}
}
}
代码示例来源: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
void triangulate () {
// seed = 4139368480425561099l;
// seed = 6559652580366669361l;
MathUtils.random.setSeed(seed);
int pointCount = 100;
points.clear();
for (int i = 0; i < pointCount; i++) {
float value;
do {
value = MathUtils.random(10, 400);
} while (points.contains(value));
points.add(value);
do {
value = MathUtils.random(10, 400);
} while (points.contains(value));
points.add(value);
}
points.add(Gdx.input.getX());
points.add(Gdx.graphics.getHeight() - Gdx.input.getY());
triangles = trianglulator.computeTriangles(points, false);
}
代码示例来源: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
renderer.begin(ShapeRenderer.ShapeType.Line);
renderer.setColor(0, 1, 0, 1);
float w = Gdx.input.getX();
label.setWidth(Gdx.input.getX() - label.getX());
label.setHeight(label.getPrefHeight());
} else {
代码示例来源:origin: libgdx/libgdx
stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY()));
Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);
if (actor != null)
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
// clear the screen, update the camera and make the sprite batch
// use its matrices.
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined);
// render all the things, we render in a y-down
// cartesian coordinate system
batch.begin();
// drawing a region, x and y will be the top left corner of the region, would be bottom left
// with y-up.
batch.draw(region, 20, 100);
// drawing text, x and y will be the top left corner for text, same as with y-up
font.draw(batch, "This is a test", 270, 100);
// drawing regions from an atlas, x and y will be the top left corner.
// you shouldn't call findRegion every frame, cache the result.
batch.draw(atlas.findRegion("badlogicsmall"), 360, 100);
// drawing a sprite created from an atlas, FIXME wut?! AtlasSprite#setPosition seems to be wrong
sprite.setColor(Color.RED);
sprite.draw(batch);
// finally we draw our current touch/mouse coordinates
font.draw(batch, Gdx.input.getX() + ", " + Gdx.input.getY(), 0, 0);
batch.end();
// tell the stage to act and draw itself
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: libgdx/libgdx
else
renderer.setColor(Color.GREEN);
renderer.rect(Gdx.input.getX() - 15, Gdx.graphics.getHeight() - Gdx.input.getY() - 15, 30, 30);
renderer.rect(x, y, 30, 30);
renderer.end();
代码示例来源:origin: libgdx/libgdx
public void render () {
horiz.setWidth(Gdx.input.getX() - horiz.getX());
horizWrap.fill();
horizWrap.expand();
horizWrap.setWidth(Gdx.input.getX() - horizWrap.getX());
代码示例来源:origin: libgdx/libgdx
batch.draw(tex, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY());
font.draw(batch, "" + Gdx.graphics.getWidth() + ", " + Gdx.graphics.getHeight(), 0, 20);
batch.end();
代码示例来源:origin: com.github.nifty-gui/nifty-libgdx-renderer
@Override
public boolean scrolled(final int amount) {
eventQueue.offer(GdxMouseInputEvent.getMouseEvent(input.getX(), input.getY(), amount, 0,
GdxMouseInputEvent.NO_BUTTON, false, false));
return true;
}
}
代码示例来源:origin: nifty-gui/nifty-gui
@Override
public boolean scrolled(final int amount) {
eventQueue.offer(GdxMouseInputEvent.getMouseEvent(input.getX(), input.getY(), amount, 0,
GdxMouseInputEvent.NO_BUTTON, false, false));
return true;
}
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-components-libgdx
@Override
protected void process(Entity e) {
final Pos pos = pm.get(e);
aimAtTmp.set(Gdx.input.getX(), Gdx.input.getY(), 0);
final Vector3 unproject = cameraSystem.camera.unproject(aimAtTmp);
pos.x = unproject.x;
pos.y = unproject.y;
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
public void layout() {
updateLinesFromModel();
// Manually update hover state
{
int screenX = Gdx.input.getX();
int screenY = Gdx.input.getY();
Vector2 localCoord = screenToLocalCoordinates(tmpVec2.set(screenX, screenY));
updateLinesHover(localCoord.x, localCoord.y);
}
}
内容来源于网络,如有侵权,请联系作者删除!