Java Code Examples for com.badlogic.gdx.Input.Keys#UP

The following examples show how to use com.badlogic.gdx.Input.Keys#UP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BattleScreenInputProcessor.java    From Norii with Apache License 2.0 6 votes vote down vote up
@Override
public boolean keyDown(int keycode) {
	switch (keycode) {
	case Keys.LEFT:
		setLeftMove(true);
		break;
	case Keys.RIGHT:
		setRightMove(true);
		break;
	case Keys.UP:
		setUpMove(true);
		break;
	case Keys.DOWN:
		setDownMove(true);
		break;
	default:
		break;
	}
	return true;
}
 
Example 2
Source File: BattleScreenInputProcessor.java    From Norii with Apache License 2.0 5 votes vote down vote up
@Override
public boolean keyUp(int keycode) {
	switch (keycode) {
	case Keys.LEFT:
		setLeftMove(false);
		break;
	case Keys.RIGHT:
		setRightMove(false);
		break;
	case Keys.UP:
		setUpMove(false);
		break;
	case Keys.DOWN:
		setDownMove(false);
		break;
	case Keys.ESCAPE:
		if (isPaused) {
			battleScreen.resume();
		} else {
			battleScreen.pause();
		}
		isPaused = !isPaused;
		break;
	case Keys.Z:
		sendKeyToBattlestate(Keys.Z);
		break;
	case Keys.Q:
		sendKeyToBattlestate(Keys.Q);
		break;
	case Keys.S:
		sendKeyToBattlestate(Keys.S);
		break;
	case Keys.D:
		sendKeyToBattlestate(Keys.D);
		break;
	default:
		break;
	}
	return true;
}
 
Example 3
Source File: GUIConsole.java    From libgdx-inGameConsole with Apache License 2.0 5 votes vote down vote up
@Override public boolean keyDown (InputEvent event, int keycode) {
	if (disabled)
		return false;

	// reset command completer because input string may have changed
	if (keycode != Keys.TAB) {
		commandCompleter.reset();
	}

	if (keycode == Keys.ENTER && !hidden) {
		commandHistory.getNextCommand(); // Makes up arrow key repeat the same command after pressing enter
		return display.submit();
	} else if (keycode == Keys.UP && !hidden) {
		input.setText(commandHistory.getPreviousCommand());
		input.setCursorPosition(input.getText().length());
		return true;
	} else if (keycode == Keys.DOWN && !hidden) {
		input.setText(commandHistory.getNextCommand());
		input.setCursorPosition(input.getText().length());
		return true;
	} else if (keycode == Keys.TAB && !hidden) {
		String s = input.getText();
		if (s.length() == 0) {
			return false;
		}
		if (commandCompleter.isNew()) {
			commandCompleter.set(exec, s);
		}
		input.setText(commandCompleter.next());
		input.setCursorPosition(input.getText().length());
		return true;
	}
	return false;
}
 
Example 4
Source File: HelpScreen.java    From FruitCatcher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean keyDown(int keycode) {
	if(keycode == Keys.BACK){
		game.gotoMenuScreen();
    }
	else if (keycode == Keys.UP && startLine > 0) {
		startLine--;
	}
	else if (keycode == Keys.DOWN && startLine < lastLineIndex) {
		startLine++;
	}		
	return true;
}
 
Example 5
Source File: ScnWidgetInputListener.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@Override
public boolean keyUp(InputEvent event, int keycode) {
	switch (keycode) {
	case Keys.UP:
	case Keys.DOWN:
	case Keys.LEFT:
	case Keys.RIGHT:
		Ctx.project.getUndoStack().add(new UndoPosition(selActor, new Vector2(undoOrg)));
	}

	return false;
}
 
Example 6
Source File: ScnWidgetInputListener.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean keyDown(InputEvent event, int keycode) {
	super.keyDown(event, keycode);
	Polygon p = null;

	if (scnWidget.getStage() == null || scnWidget.getStage().getKeyboardFocus() != scnWidget)
		return false;

	switch (keycode) {

	case Keys.ENTER:
		break;
	case Keys.BACKSPACE:
		break;
	case Keys.Z:
		if (UIUtils.ctrl()) {
			Ctx.project.getUndoStack().undo();
		}
		break;

	case Keys.FORWARD_DEL:
		BaseActor a = Ctx.project.getSelectedActor();
		if (a == null)
			return false;
		Ctx.project.getUndoStack().add(new UndoDeleteActor(Ctx.project.getSelectedScene(), a));
		Ctx.project.getSelectedScene().removeActor(a);
		Ctx.project.setModified(this, Project.NOTIFY_ELEMENT_DELETED, null, a);
		break;

	case Keys.S:
		if (UIUtils.ctrl()) {
			try {
				Ctx.project.saveProject();
			} catch (IOException e1) {
				String msg = "Something went wrong while saving the actor.\n\n" + e1.getClass().getSimpleName()
						+ " - " + e1.getMessage();
				Message.showMsgDialog(scnWidget.getStage(), "Error", msg);

				EditorLogger.printStackTrace(e1);
			}
		}
		break;

	case Keys.UP:
	case Keys.DOWN:
	case Keys.LEFT:
	case Keys.RIGHT:
		selActor = scnWidget.getSelectedActor();
		p = selActor.getBBox();
		undoOrg.set(p.getX(), p.getY());

		Ctx.project.setModified(this, Project.POSITION_PROPERTY, null, selActor);
		break;

	case Keys.PLUS:
	case 70:
		scnWidget.zoom(-1);
		break;

	case Keys.MINUS:
		scnWidget.zoom(1);
		break;

	}

	return false;
}