本文整理了Java中com.badlogic.gdx.Input.isKeyJustPressed()
方法的一些代码示例,展示了Input.isKeyJustPressed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.isKeyJustPressed()
方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:isKeyJustPressed
[英]Returns whether the key has just been pressed.
[中]返回是否刚刚按下该键。
代码示例来源:origin: libgdx/libgdx
@Override
public boolean isKeyJustPressed (int key) {
return input.isKeyJustPressed(key);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) {
if (mapType != 0) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
} else if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) {
if (mapType != 1) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
((OrthoCachedTiledMapRenderer)renderer).setBlending(true);
} else if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) {
if (mapType != 2) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
} else if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) {
if (mapType != 3) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
} else if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_5)) {
if (mapType != 4) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
} else if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_6)) {
if (mapType != 5) {
if (renderer instanceof Disposable) ((Disposable)renderer).dispose();
代码示例来源:origin: libgdx/libgdx
if (Gdx.input.isKeyJustPressed(Keys.B))
debug = !debug;
代码示例来源:origin: libgdx/libgdx
animation.action("Attack", 1, 1f, null, 0.2f);
if (Gdx.input.isKeyJustPressed(Keys.Z))
ship.parts.get(0).enabled = !ship.parts.get(0).enabled;
代码示例来源:origin: yichen0831/Bomberman_libGdx
private void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.F)) {
showFPS = !showFPS;
fpsLabel.setVisible(showFPS);
}
}
代码示例来源:origin: yichen0831/Bomberman_libGdx
public void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.B)) {
showB2DDebugRenderer = !showB2DDebugRenderer;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
paused = !paused;
if (paused) {
GameManager.getInstance().playSound("Pause.ogg");
GameManager.getInstance().pauseMusic();
} else {
GameManager.getInstance().playMusic();
}
}
}
代码示例来源:origin: LonamiWebs/Klooni1010
@Override
public void render(float delta) {
Klooni.theme.glClearBackground();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
stage.draw();
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) {
Gdx.app.exit();
}
}
代码示例来源:origin: BrentAureli/SuperMario
public void handleInput(float dt){
//control our player using immediate impulses
if(player.currentState != Mario.State.DEAD) {
if (Gdx.input.isKeyJustPressed(Input.Keys.UP))
player.jump();
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) && player.b2body.getLinearVelocity().x <= 2)
player.b2body.applyLinearImpulse(new Vector2(0.1f, 0), player.b2body.getWorldCenter(), true);
if (Gdx.input.isKeyPressed(Input.Keys.LEFT) && player.b2body.getLinearVelocity().x >= -2)
player.b2body.applyLinearImpulse(new Vector2(-0.1f, 0), player.b2body.getWorldCenter(), true);
if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE))
player.fire();
}
}
代码示例来源:origin: RoaringCatGames/libgdx-ashley-box2d-example
@Override
public void update(float deltaTime) {
super.update(deltaTime);
if(Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) {
for(Entity entity:stateQueue) {
StateComponent state = sm.get(entity);
if (state.get() == "DEFAULT") {
state.set("RUNNING");
} else {
state.set("DEFAULT");
}
}
}
stateQueue.clear();
}
代码示例来源:origin: udacity/ud406
public void update(float delta) {
if (Gdx.input.isKeyJustPressed(Keys.SPACE)) {
following = !following;
}
if (following) {
camera.position.x = target.getPosition().x;
camera.position.y = target.getPosition().y;
} else {
if (Gdx.input.isKeyPressed(Keys.A)) {
camera.position.x -= delta * Constants.CHASE_CAM_MOVE_SPEED;
}
if (Gdx.input.isKeyPressed(Keys.D)) {
camera.position.x += delta * Constants.CHASE_CAM_MOVE_SPEED;
}
if (Gdx.input.isKeyPressed(Keys.W)) {
camera.position.y += delta * Constants.CHASE_CAM_MOVE_SPEED;
}
if (Gdx.input.isKeyPressed(Keys.S)) {
camera.position.y -= delta * Constants.CHASE_CAM_MOVE_SPEED;
}
}
}
}
代码示例来源:origin: yichen0831/Bomberman_libGdx
private void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.UP) && !selected) {
GameManager.getInstance().playSound("Pickup.ogg");
currentSelection--;
if (Gdx.input.isKeyJustPressed(Input.Keys.DOWN) && !selected) {
GameManager.getInstance().playSound("Pickup.ogg");
currentSelection++;
if (!selected && (Gdx.input.isKeyJustPressed(Input.Keys.X) || Gdx.input.isKeyJustPressed(Input.Keys.Z))) {
GameManager.getInstance().playSound("Teleport.ogg");
代码示例来源:origin: LonamiWebs/Klooni1010
@Override
public void render(float delta) {
Klooni.theme.glClearBackground();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), MIN_DELTA));
stage.draw();
// After everything is drawn, showcase the current shop item
SnapshotArray<Actor> children = shopGroup.getChildren();
if (children.size > 0) {
final ShopCard card = (ShopCard) children.get(showcaseIndex);
final Batch batch = stage.getBatch();
batch.begin();
// For some really strange reason, we need to displace the particle effect
// by "buyBand.height", or it will render exactly that height below where
// it should.
// TODO Fix this - maybe use the same project matrix as stage.draw()?
// batch.setProjectionMatrix(stage.getViewport().getCamera().combined)
if (!card.showcase(batch, buyBand.getHeight())) {
showcaseIndex = (showcaseIndex + 1) % children.size;
}
batch.end();
}
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) {
goBack();
}
}
代码示例来源:origin: yichen0831/Bomberman_libGdx
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) {
player.powerUpAmmo();
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) {
player.powerUpPower();
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) {
player.powerUpSpeed();
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) {
player.powerUpKick();
if (Gdx.input.isKeyJustPressed(Input.Keys.NUM_5)) {
player.powerUpRemote();
if (Gdx.input.isKeyJustPressed(Input.Keys.X)) {
kicking = false;
if (player.kickBomb) {
if (Gdx.input.isKeyJustPressed(Input.Keys.Z) && player.remoteBomb) {
Queue<Entity> remoteBombQueue = GameManager.getInstance().getRemoteBombDeque();
代码示例来源:origin: udacity/ud406
if (Gdx.input.isKeyJustPressed(Keys.X)) {
shoot();
内容来源于网络,如有侵权,请联系作者删除!