Java 类com.badlogic.gdx.Input 实例源码

项目:ggvm    文件:PCMenu.java   
@Override
public boolean keyDown(int keycode) {
    if (currentMenuOption != null) {
        switch(keycode) {
            case Input.Keys.DOWN:
                cursorDown();
                return true;
            case Input.Keys.UP:
                cursorUp();
                return true;
            case Input.Keys.ENTER:
                menuAction();
                return true;
            case Input.Keys.ESCAPE:
                dismissMenu();
                return true;
            default:
                returnToTitleOption.resetVisited();
                break;
        }
    }
    return false;
}
项目:odb-artax    文件:CameraFollowSystem.java   
@Override
protected void process(E e) {
    if ( Gdx.input.isKeyJustPressed(Input.Keys.F9) ) lockCamera = !lockCamera;

    if ( lockCamera) return;
    if (e.wallSensorOnFloor() || e.wallSensorOnPlatform()) {
        float newTargetY = myAnimRenderSystem.roundToPixels(e.posY());
        if (targetY != newTargetY) {
            sourceY = (int) cameraSystem.camera.position.y;
            targetY = (int) newTargetY;
            cooldown = 0f;
        }
    }
    if (cooldown <= 1F) {
        cooldown += world.delta*2f;
        if (cooldown > 1f) cooldown = 1f;
        cameraSystem.camera.position.y = myAnimRenderSystem.roundToPixels(Interpolation.pow2Out.apply(sourceY,targetY, cooldown));        }
    cameraSystem.camera.position.x = myAnimRenderSystem.roundToPixels(e.posX());
    cameraSystem.camera.update();

    float maxDistance = (Gdx.graphics.getHeight() / G.CAMERA_ZOOM) * 0.5F * 0.6f;
    if (  e.posY() < cameraSystem.camera.position.y - maxDistance) {
        cameraSystem.camera.position.y = e.posY() + maxDistance;
        cameraSystem.camera.update();
    }
}
项目:PixelDungeonTC    文件:Window.java   
@Override
public void onSignal( NoosaInputProcessor.Key<GameAction> key ) {
    if (key.pressed) {
        switch (key.code) {
        case Input.Keys.BACK:
            onBackPressed();            
            break;
        case Input.Keys.MENU:
            onMenuPressed();            
            break;
        }
    }


    Game.instance.getInputProcessor().cancelKeyEvent();
}
项目:drc-sim-client    文件:StageConfigInput.java   
public static String getInputDisplayName(int type, ConfigKeymap config, String key) {
    ConfigKeymap.Input input = config.getInput(key, -1, -1, -1);
    if (input.getInput() < 0)
        return "NONE";
    if (type == KEYBOARD && input.getInput() <= 255)
        return Input.Keys.toString(input.getInput());
    else if (type == CONTROLLER) {
        if (input.getType() == ConfigKeymap.Input.TYPE_AXIS)
            return String.format(Locale.US, "Axis %d %s", input.getInput(),
                    input.getExtra() == 0 ? "negative" : "positive");
        else if (input.getType() == ConfigKeymap.Input.TYPE_POV) {
            String pov = String.valueOf(input.getExtra());
            for (PovDirection dir : PovDirection.values())
                if (dir.ordinal() == input.getExtra())
                    pov = dir.name();
            return String.format(Locale.US, "D-pad %d %s", input.getInput(), pov);
        }
        else if (input.getType() == ConfigKeymap.Input.TYPE_BUTTON)
            return String.format(Locale.US, "Button %d", input.getInput());
    }
    return String.format(Locale.US, "%d", input.getInput());
}
项目:conquest    文件:ConquestCamera.java   
public void handle() {
    if (Gdx.input.isKeyPressed(Input.Keys.W) || Gdx.input.isKeyPressed(Input.Keys.UP)) {
        translate(0, 10);
    }
    if (Gdx.input.isKeyPressed(Input.Keys.A) || Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
        translate(-10, 0);
    }
    if (Gdx.input.isKeyPressed(Input.Keys.S) || Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
        translate(0, -10);
    }
    if (Gdx.input.isKeyPressed(Input.Keys.D) || Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
        translate(10, 0);
    }
    if (Gdx.input.isKeyPressed(Input.Keys.I)) {
        zoom -= 0.05;
    }
    if (Gdx.input.isKeyPressed(Input.Keys.O)) {
        zoom += 0.05;
    }

    zoom = MathUtils.clamp(zoom, 0.5f, 2);
    position.x = MathUtils.clamp(position.x, left, right);
    position.y = MathUtils.clamp(position.y, bottom, top);
}
项目:PixelDungeonTC    文件:Scene.java   
public void create() {
    Gdx.input.setCatchBackKey(true);
    Game.instance.getInputProcessor().addKeyListener(keyListener = new Signal.Listener<NoosaInputProcessor.Key>() {
        @Override
        public void onSignal(NoosaInputProcessor.Key key) {
            if (Game.instance != null && key.pressed) {
                switch (key.code) {
                    case Input.Keys.BACK:
                    case Input.Keys.ESCAPE:
                        onBackPressed();
                        break;
                    case Input.Keys.MENU:
                    case Input.Keys.F5:
                        onMenuPressed();
                        break;
                }
            }
        }
    });
}
项目:SpaceChaos    文件:InputManager.java   
@Override
public boolean keyDown(int keycode) {
    if (keycode == Input.Keys.A || keycode == Input.Keys.LEFT) {
        left = true;
    } else if (keycode == Input.Keys.D || keycode == Input.Keys.RIGHT) {
        right = true;
    } else if (keycode == Input.Keys.W || keycode == Input.Keys.UP) {
        up = true;
    } else if (keycode == Input.Keys.S || keycode == Input.Keys.DOWN) {
        down = true;
    } else if (keycode == Input.Keys.ESCAPE) {
        escape = true;
    } else if (keycode == Input.Keys.SPACE) {
        space = true;
    }
    return true;
}
项目:SpaceChaos    文件:InputManager.java   
@Override
public boolean keyUp(int keycode) {
    if (keycode == Input.Keys.A || keycode == Input.Keys.LEFT) {
        left = false;
    } else if (keycode == Input.Keys.D || keycode == Input.Keys.RIGHT) {
        right = false;
    } else if (keycode == Input.Keys.W || keycode == Input.Keys.UP) {
        up = false;
    } else if (keycode == Input.Keys.S || keycode == Input.Keys.DOWN) {
        down = false;
    } else if (keycode == Input.Keys.ESCAPE) {
        escape = false;
    } else if (keycode == Input.Keys.SPACE) {
        space = false;
    }

    return true;
}
项目:EarthInvadersGDX    文件:MenuScreen.java   
@Override
public void tick() {
    if (play.clicked) {
        GameScreen gs = new GameScreen();
        Game.setCurrentScreen(gs);
        play.clicked = false;
    }
    if (music.released) {
        music.setSprite(Game.musicMuted() ? musicUnmuted : musicMuted);
        music.setScale(4f);
        Game.setMuted(!Game.musicMuted());
        Game.save();
        music.released = false;
    }
    play.tick();
    music.tick();

    if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) {
        Gdx.app.exit();
    }
}
项目:summer17-android    文件:PlayScreen.java   
public void handleInput(float dt) {
    //if our user is holding down mouse move our camer
    if (((Gdx.input.isKeyJustPressed(Input.Keys.UP) || controller.isUpPressed()) && hero.b2body.getLinearVelocity().y == 0)) {
        hero.b2body.applyLinearImpulse(new Vector2(0, 3f), hero.b2body.getWorldCenter(),
                true);
    }

    isObjectHit = worldContactListener.getIsObjectTouched();
    if(isObjectHit == NoObjectionGame.MUSHROOM){
        gameWin = true;
    }

    //temp climbing
    if (((Gdx.input.isKeyJustPressed(Input.Keys.DOWN) || controller.isDownPressed() && hero.b2body.getLinearVelocity().y < 1) && isObjectHit == 1000)) {
        hero.b2body.applyLinearImpulse(new Vector2(0, 2f), hero.b2body.getWorldCenter(),
                true);
    }
    if ((Gdx.input.isKeyPressed(Input.Keys.RIGHT) || controller.isRightPressed())
            && hero.b2body.getLinearVelocity().x <= 2) {
        hero.b2body.applyLinearImpulse(new Vector2(0.1f, 0), hero.b2body.getWorldCenter(), true);
    }
    if ((Gdx.input.isKeyPressed(Input.Keys.LEFT) || controller.isLeftPressed())
            && hero.b2body.getLinearVelocity().x >= -2) {
        hero.b2body.applyLinearImpulse(new Vector2(-0.1f, 0), hero.b2body.getWorldCenter(), true);
    }
}
项目:Polymorph    文件:GameScreen.java   
@Override
public boolean keyDown(int keycode) {
    switch (keycode) {
    case Input.Keys.NUMPAD_4:
        shapeHeld = Shape.TRIANGLE;
        break;
    case Input.Keys.NUMPAD_5:
        shapeHeld = Shape.CIRCLE;
        break;
    case Input.Keys.NUMPAD_6:
        shapeHeld = Shape.SQUARE;
        break;
    default:
        return false;
    }
    return true;
}
项目:Polymorph    文件:GameScreen.java   
@Override
public boolean keyUp(int keycode) {
    if (shapeHeld == null) {
        return false;
    }

    switch (keycode) {
    case Input.Keys.NUMPAD_7:
        polyGame.getPlayer().morph(shapeHeld, ShapeColor.values()[0].color);
        break;
    case Input.Keys.NUMPAD_8:
        polyGame.getPlayer().morph(shapeHeld, ShapeColor.values()[1].color);
        break;
    case Input.Keys.NUMPAD_9:
        polyGame.getPlayer().morph(shapeHeld, ShapeColor.values()[2].color);
        break;
    }
    return true;
}
项目:gdx-cclibs    文件:LiveWallpaperWrapper.java   
private void handleTouch() {
    Input input = Gdx.input;

    if (input.justTouched()) {
        swipeXStart = input.getX(0);
    }

    if (input.isTouched(0) && !input.isTouched(1)) { //only one finger down and swiping
        //Measure swipe distance since last frame and apply. Then reset for next frame.
        float swipeDelta = swipeXStart - input.getX();
        xOffsetFakeTarget += (swipeDelta / density) / DIP_TO_XOFFSET_FAKE_RATIO;
        if (xOffsetFakeTarget < 0)
            xOffsetFakeTarget = 0;
        else if (xOffsetFakeTarget > 1)
            xOffsetFakeTarget = 1;
        swipeXStart = input.getX();
    }
}
项目:ExamensArbeteTD    文件:InputHandler.java   
public void setCameraDirection() {
    if (Gdx.input.isKeyPressed(Input.Keys.W)) {
        yAxis = 1;
    } else if (Gdx.input.isKeyPressed(Input.Keys.S)) {
        yAxis = -1;
    } else {
        yAxis = 0;
    }

    if (Gdx.input.isKeyPressed(Input.Keys.D)) {
        xAxis = 1;
    } else if (Gdx.input.isKeyPressed(Input.Keys.A)) {
        xAxis = -1;
    } else {
        xAxis = 0;
    }
    _inputHandler.setCamDir(xAxis, yAxis);
}
项目:school-game    文件:InputManager.java   
/**
 * Sollte nur von Menüs aufgerufen werden.
 * Gibt die der Taste entsprechende Aktion zurück.
 *
 * @param keycode der Tastencode der Taste
 * @return die Aktion, die mit dieser Taste verknüpft ist
 */
public static Action checkMenuAction(int keycode)
{
    if (keycode == Input.Keys.UP || keycode == Input.Keys.W)
    {
        return Action.MOVE_UP;
    }

    if (keycode == Input.Keys.DOWN || keycode == Input.Keys.S)
    {
        return Action.MOVE_DOWN;
    }

    if (keycode == Input.Keys.ENTER || keycode == Input.Keys.SPACE)
    {
        return Action.MENU_SELECT;
    }

    return Action.UNKNOWN;
}
项目:school-game    文件:InputManager.java   
/**
 * Wird für Polling benutzt.
 * Fragt in jedem Frame ab, ob eine Taste im Moment gedrückt ist.
 *
 * @param action die Aktion, die abgefragt werden soll
 * @return true wenn diese Aktion im Moment aktiv ist
 */
public static boolean checkActionActive(Action action)
{
    switch (action)
    {
        case MOVE_UP:
            return Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isKeyPressed(Input.Keys.W) || checkController(action);

        case MOVE_DOWN:
            return Gdx.input.isKeyPressed(Input.Keys.DOWN) || Gdx.input.isKeyPressed(Input.Keys.S) || checkController(action);

        case MOVE_LEFT:
            return Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A) || checkController(action);

        case MOVE_RIGHT:
            return Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D) || checkController(action);

        case RUN:
            return Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT) || checkController(action);

        default:
            break;
    }

    return false;
}
项目:skycity    文件:StartScreen.java   
@Override
public void render(float delta) {
    cleanScreen();
    skyCity.batch.begin();
    skyCity.batch.setColor(1, 1, 1, alpha);
    skyCity.batch.draw(logoTexture, Config.SCREEN_WIDTH / 2 - logoTexture.getWidth() / 2, Config.SCREEN_HEIGHT / 2 - logoTexture.getHeight() / 2);
    skyCity.batch.end();

    deltaSum += delta;
    if (deltaSum > REMAIN) {
        skyCity.setScreen(new GameScreen(skyCity));
    } else {
        alpha = gradientAlpha(deltaSum);
    }

    if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY) && deltaSum >1) {
        skyCity.setScreen(new GameScreen(skyCity));
    }

}
项目:savethebunny    文件:StoryScreenController.java   
@Override
public boolean keyUp(int keycode) {
    if (keycode == Input.Keys.BACK) {
        if (mode == MODE_PHASE) {
            ((MerlinGame) game).loadMenuScreen();
        } else {
            showSelectPhase();
        }
    }
    return false;
}
项目:ShootMe    文件:TestScreen.java   
@Override
public boolean keyUp(int keycode) {

    switch (keycode) {
        case Input.Keys.LEFT:
        case Input.Keys.RIGHT:
        case Input.Keys.A:
        case Input.Keys.D:

            imagePosMovement.set(0, imagePosMovement.y);

            if(SM.input.isKeyPressed(Input.Keys.RIGHT) ||SM.input.isKeyPressed(Input.Keys.D))
                imagePosMovement.set(+7, imagePosMovement.y);

            if(SM.input.isKeyPressed(Input.Keys.LEFT) ||SM.input.isKeyPressed(Input.Keys.A))
                imagePosMovement.set(-7, imagePosMovement.y);

            break;
        case Input.Keys.DOWN:
        case Input.Keys.UP:
        case Input.Keys.W:
        case Input.Keys.S:

            imagePosMovement.set(imagePosMovement.x, 0);

            if(SM.input.isKeyPressed(Input.Keys.DOWN) ||SM.input.isKeyPressed(Input.Keys.S))
                imagePosMovement.set(-7, imagePosMovement.y);

            if(SM.input.isKeyPressed(Input.Keys.UP) ||SM.input.isKeyPressed(Input.Keys.W))
                imagePosMovement.set(+7, imagePosMovement.y);
            break;
    }

    return false;
}
项目:ggvm    文件:PCMenu.java   
@Override
public boolean keyDown(int keycode) {
    Gdx.app.log(getClass().getSimpleName(), "keyDown(" + keycode + ")");
    if (keycode != Input.Keys.ESCAPE) {
        inputProcessor.getButtonIndexToKeyCode().inverse().forcePut(keycode, currentMenuOption.buttonIndex);
        menu = topLevelMenu;
        menu.activate();
    }
    return false;
}
项目:ggvm    文件:KeyboardInputProcessor.java   
public void autoConfigure() {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        Controller controller = controllers.get(0);
        if (isXbox360Controller(controller.getName())) {
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, XBOX_360_A);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, XBOX_360_X);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, XBOX_360_LEFT_SHOULDER);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, XBOX_360_START);
        } else if (controller.getName().equals(RETRO_USB_NAME)) {
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, RETRO_USB_A);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, RETRO_USB_B);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, RETRO_USB_SELECT);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, RETRO_USB_START);
            actualAxisToAxisCode.put(Axis.X, 1);
            actualAxisToAxisCode.put(Axis.Y, 0);
        }
    }
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.A, Input.Keys.F);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.B, Input.Keys.D);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, Input.Keys.A);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.START, Input.Keys.S);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.UP, Input.Keys.UP);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.RIGHT, Input.Keys.RIGHT);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.DOWN, Input.Keys.DOWN);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.LEFT, Input.Keys.LEFT);
}
项目:ggvm    文件:KeyboardInputProcessor.java   
@Override
public boolean keyDown(int keycode) {
    if (buttonIndexToKeyCode.containsValue(keycode)) {
        int buttonIndex = buttonIndexToKeyCode.inverse().get(keycode).ordinal();
        ggvm.setButtonState(buttonIndex, true);
        if (buttonToButtonUpIndex.containsKey(buttonIndex)) {
            ggvm.setButtonState(buttonToButtonUpIndex.get(buttonIndex), false);
        }
    }
    if (keycode == Input.Keys.ESCAPE) {
        stopGGVmAndActivateMenu();
    }
    return false;
}
项目:libgdx_ui_editor    文件:MainWindow.java   
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
    if (button == Input.Buttons.RIGHT) {
        startX = x;
        startY = y;
        selectedGroup.clearAllActor();
        selectedGroup.setVisible(true);
        return true;
    }
    return super.touchDown(event, x, y, pointer, button);
}
项目:Planet-Generator    文件:Scene.java   
@Override
public boolean keyDown(int keycode) {
    switch(keycode) {
        case Input.Keys.ESCAPE:
            Gdx.app.exit();
            return true;

        case Input.Keys.F12:
            takeScreenshot();
            return true;
    }

    return false;
}
项目:feup-lpoo-armadillo    文件:GameInputPoller.java   
/**
 * Game Controller's constructor.
 *
 * @param model The current game being played by the USer.
 */
public GameInputPoller(GameModel model) {
    this.model = model;

    if (!(accelerometerAvailable = Gdx.input.isPeripheralAvailable(Input.Peripheral.Accelerometer)))
        System.err.println("Accelerometer unavailable");
}
项目:feup-lpoo-armadillo    文件:GameInputPoller.java   
/**
 * Decide what to do when the keys are pressed.
 *
 * @param delta The time elapsed since the last update
 */
private void pollKeys(float delta) {
    if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
        model.getBallModel().rotate(delta);
    } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
        model.getBallModel().rotate(delta * -1);
    }

    if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) {
        model.getBallModel().jump();
    } else if (Gdx.input.isKeyJustPressed(Input.Keys.P)) {
        model.togglePause();
    }
}
项目:libgdx-learnlib    文件:WorldController.java   
private void handleDebugInput(float deltaTime) {
    if (Gdx.app.getType() != Application.ApplicationType.Desktop) {
        return;
    }

    // Camera controls (move)
    if (!cameraHelper.hasTarget(level.bunnyHead)) {
        float camMoveSpeed = 5 * deltaTime;
        float camMoveSpeedAccelerationFactor = 5;
        if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT))
            camMoveSpeed *= camMoveSpeedAccelerationFactor;
        if (Gdx.input.isKeyPressed(Input.Keys.LEFT))
            moveCamera(-camMoveSpeed, 0);
        if (Gdx.input.isKeyPressed(Keys.RIGHT))
            moveCamera(camMoveSpeed, 0);
        if (Gdx.input.isKeyPressed(Keys.UP))
            moveCamera(0, camMoveSpeed);
        if (Gdx.input.isKeyPressed(Keys.DOWN))
            moveCamera(0, -camMoveSpeed);
        if (Gdx.input.isKeyPressed(Keys.BACKSPACE))
            cameraHelper.setPosition(0, 0);
    }

    // Camera controls (zoom)
    float camZoomSpeed = 1 * deltaTime;
    float camZoomSpeedAccelerationFactor = 5;
    if(Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT))
        camZoomSpeed *= camZoomSpeedAccelerationFactor;
    if(Gdx.input.isKeyPressed(Keys.COMMA))
        cameraHelper.addZoom(camZoomSpeed);
    if(Gdx.input.isKeyPressed(Keys.PERIOD))
        cameraHelper.addZoom(-camZoomSpeed);
    if(Gdx.input.isKeyPressed(Keys.SLASH))
        cameraHelper.setZoom(1);
}
项目:PixelDungeonTC    文件:PDInputProcessor.java   
@Override
protected GameAction keycodeToGameAction(int keycode) {
    switch (keycode) {
        case Input.Keys.BACK:
        case Input.Keys.ESCAPE:
            return GameAction.BACK;

    }
    return null;
}
项目:Parasites-of-HellSpace    文件:LoadingScreen.java   
private void update()
{
    if(!loaded)
        System.out.println("Progress: " + AssetLoader.assetManager.getProgress());

    if(AssetLoader.assetManager.update())
        loaded = true;

    if(Gdx.input.isKeyPressed(Input.Keys.SPACE) && loaded)
        game.setScreen(new GameScreen());
}
项目:drc-sim-client    文件:StageConnect.java   
@Override
public boolean keyDown(int keyCode) {
    if (keyCode == Input.Keys.ENTER) {
        Gdx.input.setOnscreenKeyboardVisible(false);
        connect();
    }
    return super.keyDown(keyCode);
}
项目:drc-sim-client    文件:Stage.java   
@Override
public boolean keyDown(int keyCode) {
    // Back Button
    if (keyCode == Input.Keys.BACK || keyCode == Input.Keys.ESCAPE) {
        this.onBackButtonPressed();
        return true;
    }
    // Fullscreen Button
    if (Gdx.input.isKeyPressed(Input.Keys.F11)) {
        toggleFullscreen();
        return true;
    }
    return false;
}
项目:conquest    文件:Manager.java   
@Override
public boolean keyUp(InputEvent event, int keycode) {
    if (!Manager.isVisible()) return false;
    if (Input.Keys.Q == keycode) {
        send();
    }
    if (Input.Keys.E == keycode || Input.Keys.ENTER == keycode) {
        sendMax();
    }

    return false;
}
项目:GDX-Engine    文件:TiledScene.java   
/**
     * Update the camera using the default setting of engine so you can control
     * the camera by keyboard like magnification or translation
     * 
     * @param gameTime
     */
    public void updateCamera(int key) {

        if (!enableDefaultCameraController)
            return;
        if (key ==(Input.Keys.Z)) {
            mainCamera.zoom += 0.02;
        }
        if (key==(Input.Keys.X)) {
            mainCamera.zoom -= 0.02;
        }
        if (key==(Input.Keys.A)) {
//          if (mainCamera.position.x > -WORLD_WIDTH / 2)
                mainCamera.translate(-10, 0, 0);
        }
        if (key==(Input.Keys.D)) {
//          if (mainCamera.position.x < WORLD_WIDTH / 2)
                mainCamera.translate(10, 0, 0);
        }
        if (key==(Input.Keys.S)) {
//          if (mainCamera.position.y > -WORLD_HEIGHT / 2)
                mainCamera.translate(0, -10, 0);
        }
        if (key==(Input.Keys.W)) {
//          if (mainCamera.position.y < WORLD_HEIGHT / 2)
                mainCamera.translate(0, 10, 0);
        }
        if (key==(Input.Keys.C)) {
            mainCamera.rotate(-rotationSpeed, 0, 0, 1);
        }
        if (key==(Input.Keys.V)) {
            mainCamera.rotate(rotationSpeed, 0, 0, 1);
        }
    }
项目:GDX-Engine    文件:TestCamera.java   
private void handleInput() {
        if(Gdx.input.isKeyPressed(Input.Keys.Z)) {
                cam.zoom += 0.02;
        }
        if(Gdx.input.isKeyPressed(Input.Keys.X)) {
                cam.zoom -= 0.02;
        }
        if(Gdx.input.isKeyPressed(Input.Keys.A)) {
                if (cam.position.x > -WORLD_WIDTH/2)
                        cam.translate(-10, 0, 0);
        }
        if(Gdx.input.isKeyPressed(Input.Keys.D)) {
                if (cam.position.x < WORLD_WIDTH/2)
                        cam.translate(10, 0, 0);
        }
        if(Gdx.input.isKeyPressed(Input.Keys.S)) {
                if (cam.position.y > -WORLD_HEIGHT/2)
                        cam.translate(0, -10, 0);
        }
        if(Gdx.input.isKeyPressed(Input.Keys.W)) {
                if (cam.position.y < WORLD_HEIGHT/2)
                        cam.translate(0, 10, 0);
        }
        if(Gdx.input.isKeyPressed(Input.Keys.C)) {
                cam.rotate(-rotationSpeed, 0, 0, 1);
        }
        if(Gdx.input.isKeyPressed(Input.Keys.V)) {
                cam.rotate(rotationSpeed, 0, 0, 1);
        }
}
项目:INFSEN01-2    文件:GDXMouse.java   
public IOption<Point> click() {
    if(Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
        return new Some<Point>(new Point(
            (float)Gdx.input.getX(),
            (float)Gdx.input.getY()));
    }
    else {
        return new None<Point>();
    }
}
项目:INFSEN01-2    文件:DefaultUpdateVisitor.java   
@Override
public void updateButton(Button element, Float dt) {
    if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
        if (element.
                contains(new Point(
                        (float) Gdx.input.getX(),
                        (float) Gdx.input.getY()
                ))) {
            element.color = Color.BLUE;
            element.action.run();
        }
    } else {
        element.color = Color.WHITE;
    }
}
项目:INFSEN01-2    文件:DefaultUpdateVisitor.java   
@Override
public void updateButton(Button element, Float dt) {
    if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
        if (element.
                contains(new Point(
                        (float) Gdx.input.getX(),
                        (float) Gdx.input.getY()
                ))) {
            element.color = Color.BLUE;
            element.action.run();
        }
    } else {
        element.color = Color.WHITE;
    }
}
项目:My-game-StarComm    文件:Hero.java   
public void update() {
    if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
        position.y += speed;
        if (position.y > 720) position.y = -60;
    }
    if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
        position.x -= speed;
        if (position.x < 0) position.x = 0;
    }
    if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
        position.x += speed;
        if (position.x > 1200) position.x = 1200;
    }
    if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
        position.y -= speed;
        if (position.y < -60) position.y = 720;
    }
    if(Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
        fireCounter++;
        if(fireCounter > fireRate) {
            fireCounter = 0;
            for (int i = 0; i < MyGdxGame.bullets.length; i++) {
                if(!MyGdxGame.bullets[i].isActive()) {
                    MyGdxGame.bullets[i].setup(position.x, position.y);
                    break;
                }
            }
        }
    }
}
项目:GangsterSquirrel    文件:SplashScreen.java   
/**
 * Handle the input
 * @param deltaTime the time between the current and the last frame
 */
private void handleInput(float deltaTime) {
    if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE) || Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) {
        game.setScreen(new MainMenu(game));
    }

    if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
        game.exitApplication("User exited application from the splash screen");
    }
}
项目:SpaceChaos    文件:InputManager.java   
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
    if (button == Input.Buttons.LEFT) {
        leftMouse = true;
    } else if (button == Input.Buttons.RIGHT) {
        rightMouse = true;
    }
    return false;
}