本文整理汇总了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;
}
示例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();
}
}
示例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();
}
示例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());
}
示例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);
}
示例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;
}
}
}
});
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}