當前位置: 首頁>>代碼示例>>Java>>正文


Java Input類代碼示例

本文整理匯總了Java中com.badlogic.gdx.Input的典型用法代碼示例。如果您正苦於以下問題:Java Input類的具體用法?Java Input怎麽用?Java Input使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Input類屬於com.badlogic.gdx包,在下文中一共展示了Input類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: keyDown

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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;
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:24,代碼來源:PCMenu.java

示例2: process

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:DaanVanYperen,項目名稱:odb-artax,代碼行數:27,代碼來源:CameraFollowSystem.java

示例3: onSignal

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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();
}
 
開發者ID:kurtyu,項目名稱:PixelDungeonTC,代碼行數:17,代碼來源:Window.java

示例4: getInputDisplayName

import com.badlogic.gdx.Input; //導入依賴的package包/類
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());
}
 
開發者ID:rolandoislas,項目名稱:drc-sim-client,代碼行數:23,代碼來源:StageConfigInput.java

示例5: handle

import com.badlogic.gdx.Input; //導入依賴的package包/類
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);
}
 
開發者ID:conquest,項目名稱:conquest,代碼行數:25,代碼來源:ConquestCamera.java

示例6: create

import com.badlogic.gdx.Input; //導入依賴的package包/類
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;
				}
			}
		}
	});
}
 
開發者ID:kurtyu,項目名稱:PixelDungeonTC,代碼行數:21,代碼來源:Scene.java

示例7: keyDown

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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;
}
 
開發者ID:opensourcegamedev,項目名稱:SpaceChaos,代碼行數:18,代碼來源:InputManager.java

示例8: keyUp

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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;
}
 
開發者ID:opensourcegamedev,項目名稱:SpaceChaos,代碼行數:19,代碼來源:InputManager.java

示例9: tick

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:MrGussio,項目名稱:EarthInvadersGDX,代碼行數:22,代碼來源:MenuScreen.java

示例10: handleInput

import com.badlogic.gdx.Input; //導入依賴的package包/類
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);
    }
}
 
開發者ID:MissionBit,項目名稱:summer17-android,代碼行數:27,代碼來源:PlayScreen.java

示例11: keyDown

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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;
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:18,代碼來源:GameScreen.java

示例12: keyUp

import com.badlogic.gdx.Input; //導入依賴的package包/類
@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;
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:20,代碼來源:GameScreen.java

示例13: handleTouch

import com.badlogic.gdx.Input; //導入依賴的package包/類
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();
    }
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:19,代碼來源:LiveWallpaperWrapper.java

示例14: setCameraDirection

import com.badlogic.gdx.Input; //導入依賴的package包/類
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);
}
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:19,代碼來源:InputHandler.java

示例15: checkMenuAction

import com.badlogic.gdx.Input; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:27,代碼來源:InputManager.java


注:本文中的com.badlogic.gdx.Input類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。