本文整理了Java中com.badlogic.gdx.Input.isKeyPressed()
方法的一些代码示例,展示了Input.isKeyPressed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.isKeyPressed()
方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:isKeyPressed
[英]Returns whether the key is pressed.
[中]返回是否按下该键。
代码示例来源:origin: libgdx/libgdx
static public boolean ctrl () {
if (isMac)
return Gdx.input.isKeyPressed(Keys.SYM);
else
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean ctrl () {
if (isMac)
return Gdx.input.isKeyPressed(Keys.SYM);
else
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean ctrl () {
if (isMac)
return Gdx.input.isKeyPressed(Keys.SYM);
else
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean ctrl () {
if (isMac)
return Gdx.input.isKeyPressed(Keys.SYM);
else
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean isKeyPressed (int key) {
return input.isKeyPressed(key);
}
代码示例来源:origin: libgdx/libgdx
static public boolean alt () {
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean alt () {
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean shift () {
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean alt () {
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean shift () {
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean shift () {
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean shift () {
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
static public boolean alt () {
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
}
代码示例来源:origin: libgdx/libgdx
public boolean scrolled (int amount) {
if (!Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) return false;
duration -= amount / 15f;
duration = MathUtils.clamp(duration, 0, Float.POSITIVE_INFINITY);
return true;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void update () {
// If the left or right key is pressed, rotate the character and update its physics update accordingly.
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
characterTransform.rotate(0, 1, 0, 5f);
ghostObject.setWorldTransform(characterTransform);
}
if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
characterTransform.rotate(0, 1, 0, -5f);
ghostObject.setWorldTransform(characterTransform);
}
// Fetch which direction the character is facing now
characterDirection.set(-1,0,0).rot(characterTransform).nor();
// Set the walking direction accordingly (either forward or backward)
walkDirection.set(0,0,0);
if (Gdx.input.isKeyPressed(Keys.UP))
walkDirection.add(characterDirection);
if (Gdx.input.isKeyPressed(Keys.DOWN))
walkDirection.add(-characterDirection.x, -characterDirection.y, -characterDirection.z);
walkDirection.scl(4f * Gdx.graphics.getDeltaTime());
// And update the character controller
characterController.setWalkDirection(walkDirection);
// Now we can update the world as normally
super.update();
// And fetch the new transformation of the character (this will make the model be rendered correctly)
ghostObject.getWorldTransform(characterTransform);
}
代码示例来源:origin: libgdx/libgdx
boolean calculatePositionAndValue (float x, float y) {
final SliderStyle style = getStyle();
final Drawable knob = getKnobDrawable();
final Drawable bg = (disabled && style.disabledBackground != null) ? style.disabledBackground : style.background;
float value;
float oldPosition = position;
final float min = getMinValue();
final float max = getMaxValue();
if (vertical) {
float height = getHeight() - bg.getTopHeight() - bg.getBottomHeight();
float knobHeight = knob == null ? 0 : knob.getMinHeight();
position = y - bg.getBottomHeight() - knobHeight * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (height - knobHeight));
position = Math.max(Math.min(0, bg.getBottomHeight()), position);
position = Math.min(height - knobHeight, position);
} else {
float width = getWidth() - bg.getLeftWidth() - bg.getRightWidth();
float knobWidth = knob == null ? 0 : knob.getMinWidth();
position = x - bg.getLeftWidth() - knobWidth * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (width - knobWidth));
position = Math.max(Math.min(0, bg.getLeftWidth()), position);
position = Math.min(width - knobWidth, position);
}
float oldValue = value;
if (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT)) value = snap(value);
boolean valueSet = setValue(value);
if (value == oldValue) position = oldPosition;
return valueSet;
}
代码示例来源:origin: libgdx/libgdx
boolean calculatePositionAndValue (float x, float y) {
final SliderStyle style = getStyle();
final Drawable knob = getKnobDrawable();
final Drawable bg = (disabled && style.disabledBackground != null) ? style.disabledBackground : style.background;
float value;
float oldPosition = position;
final float min = getMinValue();
final float max = getMaxValue();
if (vertical) {
float height = getHeight() - bg.getTopHeight() - bg.getBottomHeight();
float knobHeight = knob == null ? 0 : knob.getMinHeight();
position = y - bg.getBottomHeight() - knobHeight * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (height - knobHeight));
position = Math.max(Math.min(0, bg.getBottomHeight()), position);
position = Math.min(height - knobHeight, position);
} else {
float width = getWidth() - bg.getLeftWidth() - bg.getRightWidth();
float knobWidth = knob == null ? 0 : knob.getMinWidth();
position = x - bg.getLeftWidth() - knobWidth * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (width - knobWidth));
position = Math.max(Math.min(0, bg.getLeftWidth()), position);
position = Math.min(width - knobWidth, position);
}
float oldValue = value;
if (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT)) value = snap(value);
boolean valueSet = setValue(value);
if (value == oldValue) position = oldPosition;
return valueSet;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
viewport.apply();
mapRenderer.setView(cam);
mapRenderer.render();
if (Gdx.input.isKeyPressed(Keys.ESCAPE)) {
if (DELETE_DELETEME_FOLDER_ON_EXIT) {
FileHandle deleteMeHandle = Gdx.files.local(MAP_PATH);
deleteMeHandle.deleteDirectory();
}
dispose();
Gdx.app.exit();
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
viewport.apply();
mapRenderer.setView(cam);
mapRenderer.render();
if (Gdx.input.isKeyPressed(Keys.ESCAPE)) {
if (DELETE_DELETEME_FOLDER_ON_EXIT) {
FileHandle deleteMeHandle = Gdx.files.local(MAP_PATH);
deleteMeHandle.deleteDirectory();
}
dispose();
Gdx.app.exit();
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
GL20 gl = Gdx.gl20;
gl.glClearColor(0, 0, 0, 0);
gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
gl.glEnable(GL20.GL_DEPTH_TEST);
cam.update();
modelBatch.begin(cam);
int visible = 0;
for (int i = 0; i < instances.length; i++) {
instances[i].transform.getTranslation(pos);
if (cam.frustum.sphereInFrustum(pos, 1)) {
((ColorAttribute)instances[i].materials.get(0).get(ColorAttribute.Diffuse)).color.set(Color.WHITE);
visible++;
} else {
((ColorAttribute)instances[i].materials.get(0).get(ColorAttribute.Diffuse)).color.set(Color.RED);
}
modelBatch.render(instances[i]);
}
modelBatch.end();
if (Gdx.input.isKeyPressed(Keys.A)) cam.rotate(20 * Gdx.graphics.getDeltaTime(), 0, 1, 0);
if (Gdx.input.isKeyPressed(Keys.D)) cam.rotate(-20 * Gdx.graphics.getDeltaTime(), 0, 1, 0);
gl.glDisable(GL20.GL_DEPTH_TEST);
batch.begin();
font.draw(batch, "visible: " + visible + "/100" + ", fps: " + Gdx.graphics.getFramesPerSecond(), 0, 20);
batch.end();
}
内容来源于网络,如有侵权,请联系作者删除!