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); }
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); }
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); }
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); }
@Override public boolean isKeyPressed (int key) { return input.isKeyPressed(key); }
static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); }
static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); }
static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); }
static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); }
static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); }
static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); }
static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); }
static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); }
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; }
@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); }
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; }
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; }
@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(); } }
@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(); } }
@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(); }