Java 类com.badlogic.gdx.Input.Buttons 实例源码
项目:Space-Bombs
文件:KeyboardInputProcessor.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
anyKey = true;
if(button == Buttons.LEFT)
{
leftButton = true;
}
if(button == Buttons.RIGHT)
{
rightButton = true;
}
return false;
}
项目:Space-Bombs
文件:KeyboardInputProcessor.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int buttonCode) {
anyKey = false;
if(buttonCode == Buttons.LEFT)
{
leftButton = false;
}
if(buttonCode == Buttons.RIGHT)
{
rightButton = false;
}
return false;
}
项目:exterminate
文件:CameraController.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (PAUSED)
return false;
if (System.currentTimeMillis() - timeLastClick < 200) {
}
timeLastClick = System.currentTimeMillis();
boutonClicked = button;
if (button == Buttons.LEFT) {
ship.attack();
}
return true;
}
项目:RavTech
文件:ScriptLoader.java
private void initEnvironment() {
ObjectMap<String, Object> values = new ObjectMap<String, Object>();
values.put("Keys", Keys.class);
values.put("Input", RavTech.input);
values.put("Debug", Debug.class);
values.put("Vector2", Vector2.class);
values.put("Color", Color.class);
values.put("Buttons", Buttons.class);
values.put("GameObject", GameObject.class);
values.put("ComponentType", ComponentType.class);
values.put("RavTech", RavTech.class);
values.put("Settings", RavTech.settings);
values.put("Graphics", Gdx.graphics);
values.put("Box2DWorld", RavTech.sceneHandler.box2DWorld);
values.put("Net", Gdx.net);
this.environment = values;
}
项目:eamaster
文件:RayPickRagdollTest.java
@Override
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
boolean result = false;
if (button == Buttons.LEFT) {
if (pickConstraint != null) {
((btDynamicsWorld)world.collisionWorld).removeConstraint(pickConstraint);
pickConstraint.dispose();
pickConstraint = null;
result = true;
}
if (pickedBody != null) {
pickedBody.forceActivationState(Collision.ACTIVE_TAG);
pickedBody.setDeactivationTime(0f);
pickedBody = null;
}
}
return result ? result : super.touchUp(screenX, screenY, pointer, button);
}
项目:METRO
文件:PlayingField.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button)
{
boolean processed = false;
if (_cityView != null)
{
processed = true;
}
if (button == Buttons.MIDDLE) // for drag-mode
{
_dragMode = true;
processed = true;
}
return processed;
}
项目:METRO
文件:PlayingField.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button)
{
boolean processed = false;
if (_cityView != null)
{
processed = true;
}
if (button == Buttons.MIDDLE) // for drag-mode
{
_dragMode = false;
processed = true;
}
return processed;
}
项目:METRO
文件:Window.java
@Override
public boolean mouseClicked(int screenX, int screenY, int mouseButton)
{
super.mouseClicked(screenX, screenY, mouseButton);
// Check for drag-mode:
if (isMouseOnWindow(screenX, screenY)
&& mouseButton == Buttons.LEFT)
{
_dragMode = true;
_oldMousePos = new Point(screenX, screenY);
closeIfNeeded(screenX, screenY, mouseButton);
return true;
}
return false;
}
项目:taloonerrl
文件:InputSystem.java
@Override
public boolean touchDown(final int _screenX, final int _screenY, final int _pointer, final int _button) {
boolean processed = false;
if (_button == Buttons.LEFT) {
// TODO check if UI has been clicked
// do things if the cursor is in the visible area
if (FovWrapper.getInstance().isLit(mouseOverX, mouseOverY)) {
processed = toggleHighlightedActors();
}
if (!processed) {
processed = addPlayerWalkPath();
}
return processed;
}
return processed;
}
项目:Roguelike
文件:InventoryPanel.java
@Override
public void handleDataClicked( Object data, InputEvent event, float x, float y )
{
Item item = (Item) data;
if ( event.getButton() == Buttons.RIGHT )
{
// show context menu:
// Unequip, use?, destory
Global.CurrentLevel.player.getInventory().removeItem( item );
Global.CurrentLevel.player.tile[ 0 ][ 0 ].items.add( item );
}
else
{
if ( item.getMainSlot() != null )
{
Global.CurrentLevel.player.getInventory().toggleEquip( item );
}
}
}
项目:SpaceProject
文件:MyScreenAdapter.java
@Override
public void render(float delta) {
cam.update();
batch.setProjectionMatrix(cam.combined);
shape.setProjectionMatrix(cam.combined);
//adjust zoom
zoomCamera(delta);
if (Gdx.input.isButtonPressed(Buttons.MIDDLE)) {
cam.zoom = 1;
setZoomTarget(1);
}
}
项目:Virtual-Evil
文件:MenuButtons.java
public void checkClicks() {
if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
for (int id = 0; id < NUM_BUTTONS; id++) {
if (isCursorOnButton(id)) {
switch (id) {
case 0: // play
game.getGsm().setCurrentState(StateType.PLAY);
break;
case 1: // new game
game.getGsm().startNewGame();
break;
case 2: // options
// TODO
break;
case 3: // quit
Gdx.app.exit();
break;
default:
break;
}
// at most 1 button should be pressed with a single click
break;
}
}
}
}
项目:umbracraft
文件:WindowLayout.java
/** Updates the stage and checks for any input. */
public void update() {
stage.act();
// invoke on touch only once
if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
if (!isTouching) {
if (typeListener != null) {
typeListener.invoke(InputCode.CONFIRM);
}
isTouching = true;
}
} else {
isTouching = false;
}
}
项目:rts-engine
文件:SelectionListener.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (button == Buttons.LEFT) {
leftDown = false;
screenY = Gdx.graphics.getHeight() - screenY;
int mapX = (int) (screenX + RTSGame.getCamera().pos.x - RTSGame.getCamera().canvasWidth / 2);
int mapY = (int) (screenY + RTSGame.getCamera().pos.y - RTSGame.getCamera().canvasHeight / 2);
if (selection.active && selection.start.x != screenX && selection.start.y != screenY) {
selection.select();
selection.active = false;
} else {
selection.selectOrMove(mapX, mapY);
selection.active = false;
}
return true;
} else if (button == Buttons.RIGHT) {
selection.clearSelection();
selection.active = false;
return true;
}
return false;
}
项目:libgdxcn
文件:RayPickRagdollTest.java
@Override
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
boolean result = false;
if (button == Buttons.LEFT) {
if (pickConstraint != null) {
((btDynamicsWorld)world.collisionWorld).removeConstraint(pickConstraint);
pickConstraint.dispose();
pickConstraint = null;
result = true;
}
if (pickedBody != null) {
pickedBody.forceActivationState(Collision.ACTIVE_TAG);
pickedBody.setDeactivationTime(0f);
pickedBody = null;
}
}
return result ? result : super.touchUp(screenX, screenY, pointer, button);
}
项目:libgdxcn
文件:InputTest.java
@Override
public void render () {
if (Gdx.input.justTouched()) {
Gdx.app.log("Input Test", "just touched, button: " + (Gdx.input.isButtonPressed(Buttons.LEFT) ? "left " : "")
+ (Gdx.input.isButtonPressed(Buttons.MIDDLE) ? "middle " : "")
+ (Gdx.input.isButtonPressed(Buttons.RIGHT) ? "right" : "")
+ (Gdx.input.isButtonPressed(Buttons.BACK) ? "back" : "")
+ (Gdx.input.isButtonPressed(Buttons.FORWARD) ? "forward" : ""));
}
for (int i = 0; i < 10; i++) {
if (Gdx.input.getDeltaX(i) != 0 || Gdx.input.getDeltaY(i) != 0) {
Gdx.app.log("Input Test", "delta[" + i + "]: " + Gdx.input.getDeltaX(i) + ", " + Gdx.input.getDeltaY(i));
}
}
// Gdx.input.setCursorPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
// if(Gdx.input.isTouched()) {
// Gdx.app.log("Input Test", "is touched");
// }
}
项目:ShapeOfThingsThatWere
文件:MenuBuilder.java
public void buildNotificationMenu() {
List<Notification> notifs = notifications.getNotifications();
notifMenu.clear();
if (notifs.isEmpty())
notifMenu.addLabel("No notifications");
else
for (Notification n : notifs) {
Button b = notifMenu.addButtonSprite(n.type, n.msg, () -> {
inputManager.reloadMenus();
if (n.action != null)
n.action.run();
}, true);
b.addListener(new ClickListener(Buttons.RIGHT) {
@Override
public void clicked(InputEvent event, float x, float y) {
notifications.discard(n);
inputManager.reloadMenus();
}
});
}
notifMenu.addToStage(stage, Gdx.graphics.getWidth() - 400, min(512, notifMenu.getTable().getPrefHeight()), false);
}
项目:gaiasky
文件:Link.java
private void initialize() {
this.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof InputEvent) {
Type type = ((InputEvent) event).getType();
// Click
if (type == Type.touchUp && ((InputEvent) event).getButton() == Buttons.LEFT) {
Gdx.net.openURI(linkURL);
} else if (type == Type.enter) {
Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0));
} else if (type == Type.exit) {
Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
}
return true;
}
return false;
}
});
}
项目:fluid-simulator-v2
文件:FluidSimulatorSPH.java
public boolean touchDown(int x, int y, int pointer, int button) {
touching = true;
camera.unproject(testPoint.set(x, y, 0));
testPoint2D.x = testPoint.x;
testPoint2D.y = testPoint.y;
if (button == Buttons.LEFT) {
if (!IS_DESKTOP) {
isRepulsing = true;
isAttracting = false;
} else {
isAttracting = false;
isRepulsing = false;
}
}
if (button == Buttons.RIGHT) {
isAttracting = true;
}
if (button == Buttons.MIDDLE) {
isRepulsing = true;
}
return false;
}
项目:vis-editor
文件:EntityManipulatorModule.java
@Override
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
if (scene.getActiveLayer().locked) return;
currentTool.touchUp(event, x, y, pointer, button);
if (button == Buttons.RIGHT && mouseDragged == false) {
if (entitiesSelection.size() > 0) {
menuX = camera.getInputX();
menuY = camera.getInputY();
buildSelectedEntitiesPopupMenu();
entityPopupMenu.showMenu(event.getStage(), event.getStageX(), event.getStageY());
} else
generalPopupMenu.showMenu(event.getStage(), event.getStageX(), event.getStageY());
}
mouseDragged = false;
}
项目:Stray-core
文件:Slider.java
@Override
public void render(Main main) {
main.batch.draw(main.manager.get(AssetMap.get("guislider"), Texture.class), x, y, width,
height);
main.batch.draw(main.manager.get(AssetMap.get("guisliderarrow"), Texture.class), x
+ ((width - 32) * slider), y, 32, 32);
if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
if (Main.getInputX() >= x + ((width - 32) * slider)
&& Main.getInputX() <= x + ((width - 32) * slider) + 32) {
if (Main.convertY(Main.getInputY()) >= y
&& Main.convertY(Main.getInputY()) <= y + height) {
grabbed = true;
}
}
} else {
grabbed = false;
}
if (grabbed) {
slider = MathUtils.clamp(((Main.getInputX() - x)) / (width - 32f), 0f, 1f);
}
}
项目:c2d-engine
文件:SceneHelper.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
dragTemp.set(Engine.screenToWorld(screenX, screenY));
secondData = null;
float dst = 0;
if (data != null) {
dst = data.position.dst(dragTemp);
}
if (dst > 100 && dst < 150) {
rotateOn = true;
} else {
data = null;
//find the first data //
if (button == Buttons.LEFT) {
box2dAABBTestPoint.set(dragTemp).scl(1f / Box2dObject.RADIO);
PhysicalWorld.WORLD.QueryAABB(callback, box2dAABBTestPoint.x - 0.1f, box2dAABBTestPoint.y - 0.1f, box2dAABBTestPoint.x + 0.1f, box2dAABBTestPoint.y + 0.1f);
}
}
return super.touchDown(screenX, screenY, pointer, button);
}
项目:c2d-engine
文件:RectangleHelper.java
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
if (button == Buttons.LEFT) {
if (Click.NONE == click) {
secondPoint.set(Engine.screenToWorld(x, y));
click = Click.FIRST;
// do start
} else if (click == Click.FIRST) {
secondPoint.set(Engine.screenToWorld(x, y));
float width = secondPoint.x - worldCenter.x;
float height = secondPoint.y - worldCenter.y;
model.width = Math.abs(width) * 2;
model.height = Math.abs(height) * 2;
updateToUI();
click = Click.NONE;
// do end
}
}
return super.touchDown(x, y, pointer, button);
}
项目:c2d-engine
文件:CircleHelper.java
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
if (button == Buttons.LEFT) {
if (Click.NONE == click) {
secondPoint.set(Engine.screenToWorld(x, y));
click = Click.FIRST;
// do start
} else if (Click.FIRST == click) {
secondPoint.set(Engine.screenToWorld(x, y));
if (worldCenter.dst(secondPoint) > 0) {
model.radius = worldCenter.dst(secondPoint);
updateToUI();
click = Click.NONE;
// do end
}
}
}
return super.touchDown(x, y, pointer, button);
}
项目:c2d-engine
文件:PolygonHelper.java
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
if (button == Buttons.LEFT) {
if (button == Buttons.LEFT) {
if (snapPoint == null) {
Vector2 newPoint = new Vector2(Engine.screenToWorld(x, y));
snapPoint = newPoint;
model.polygon.add(newPoint);
updateToUI();
}
}
} else if (button == Buttons.RIGHT) {
if (null != snapPoint) {
if (model.polygon.size() > 3) {
model.polygon.remove(snapPoint);
updateToUI();
}
}
}
return super.touchDown(x, y, pointer, button);
}
项目:vtm
文件:MotionHandler.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (pointer >= 10)
return true;
if (button != Buttons.LEFT)
return false;
mTime = Gdx.input.getCurrentEventTime();
if (mPointerDown++ == 0) {
mDownTime = getTime();
mType = MotionEvent.ACTION_DOWN;
} else {
mType = MotionEvent.ACTION_POINTER_DOWN;
}
mPointerX[pointer] = mCurX = screenX;
mPointerY[pointer] = mCurY = screenY;
mPointer = pointer;
//GdxMap.log.debug("down " + screenX + ":" + screenY
// + " / " + pointer + " " + mPointerDown
// + " " + (getTime() - mDownTime));
mMap.input.fire(null, this);
return true;
}
项目:2D-Universe
文件:Game.java
@Override
public void render() {
// Call to method that executes the game logic
logic();
// clear
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
// actual render
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeType.Line);
//When left mouse button is pressed, render line
if (Gdx.input.isButtonPressed(Buttons.LEFT))
shapeRenderer.line(
lineStartX,
lineStartY,
Gdx.input.getX() + camera.position.x
- Gdx.graphics.getWidth() / 2,
Gdx.input.getY() + camera.position.y
- Gdx.graphics.getHeight() / 2);
//Draw every gravity point in the universe
GravityPoint.drawAll(shapeRenderer);
shapeRenderer.end();
}
项目:mini2Dx
文件:ButtonRenderNode.java
@Override
public ActionableRenderNode mouseDown(int screenX, int screenY, int pointer, int button) {
if (!isIncludedInRender()) {
return null;
}
if (button != Buttons.LEFT && button != Buttons.RIGHT && button != Buttons.MIDDLE) {
return null;
}
if (!element.isEnabled()) {
return null;
}
if (outerArea.contains(screenX, screenY)) {
setState(NodeState.ACTION);
return this;
}
return null;
}
项目:mini2Dx
文件:CheckboxRenderNode.java
@Override
public ActionableRenderNode mouseDown(int screenX, int screenY, int pointer, int button) {
if (!isIncludedInRender()) {
return null;
}
if (button != Buttons.LEFT) {
return null;
}
if (!element.isEnabled()) {
return null;
}
if (outerArea.contains(screenX, screenY)) {
setState(NodeState.ACTION);
return this;
}
return null;
}
项目:mini2Dx
文件:SliderRenderNode.java
@Override
public ActionableRenderNode mouseDown(int screenX, int screenY, int pointer, int button) {
if (!isIncludedInRender()) {
return null;
}
if (button != Buttons.LEFT) {
return null;
}
if (!element.isEnabled()) {
return null;
}
if (outerArea.contains(screenX, screenY)) {
setState(NodeState.ACTION);
if (sliderPosition.contains(screenX - getContentRenderX(), screenY - getContentRenderY())) {
dragging = true;
} else {
dragging = false;
}
return this;
}
return null;
}
项目:mini2Dx
文件:RadioButtonRenderNode.java
@Override
public ActionableRenderNode mouseDown(int screenX, int screenY, int pointer, int button) {
if (!isIncludedInRender()) {
return null;
}
if (button != Buttons.LEFT) {
return null;
}
if (!element.isEnabled()) {
return null;
}
if (outerArea.contains(screenX, screenY)) {
setState(NodeState.ACTION);
return this;
}
return null;
}
项目:SpaceGame
文件:SelectionSystem.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (checkProcessing() && button == Buttons.LEFT) {
Vector3 vec = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
selectionBegin = new Vector2(vec.x, vec.y);
return true;
}
return false;
}
项目:SpaceGame
文件:SelectionSystem.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (checkProcessing() && button == Buttons.LEFT) {
Vector3 vec = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
selectionEnd = new Vector2(vec.x, vec.y);
return true;
}
return false;
}
项目:Les-Chroniques-de-Norwand
文件:UserEvent.java
/**Default constructor for a TouchEvent*/
public UserEvent(int x,int y){
this.type = TYPE_MEVENT;
this.value = Buttons.LEFT;
this.x = x;
this.y = y;
}
项目:Quilly-s-Castle
文件:InputComponent.java
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (Buttons.LEFT == button) {
keyPressedMap.put(Keys.SELECT, true);
} else {
keyPressedMap.put(Keys.DESELECT, true);
}
mouseLocation.set(screenX, screenY, 0);
inputChanged = true;
return true;
}
项目:Quilly-s-Castle
文件:InputComponent.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (Buttons.LEFT == button) {
keyPressedMap.put(Keys.SELECT, false);
} else {
keyPressedMap.put(Keys.DESELECT, false);
}
mouseLocation.set(screenX, screenY, 0);
inputChanged = true;
return true;
}
项目:exterminate
文件:CameraController.java
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (PAUSED)
return false;
boutonClicked = 0;
if (button == Buttons.LEFT) {
} else {
}
return true;
}
项目:advio
文件:LevelCompleteScreen.java
@Override
public void render(float delta) {
batch.begin();
Advio.instance.font.draw(batch, "Level Complete", Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 1.25f,
0, Align.center, false);
Advio.instance.sfont.draw(batch, "Click for the next level.", Gdx.graphics.getWidth() / 2,
Gdx.graphics.getHeight() / 2, 0, Align.center, false);
batch.end();
if (Gdx.input.isButtonPressed(Buttons.LEFT))
Advio.instance.setScreen(new GameScreen(Advio.instance.constants.getLevel(nextLevel)));
}
项目:fabulae
文件:PlayerCharacterPortrait.java
public boolean changed (ChangeEvent event, Actor actor) {
if (actor instanceof StatBar) {
return false;
}
if (UIManager.getDisplayedCharacter() != null) {
if (!pc.equals(UIManager.getDisplayedCharacter())) {
if (levelUpIndicator.equals(actor) && !UIManager.isPerksScreenOpen()) {
UIManager.togglePerks(pc);
} else {
UIManager.switchDisplayedCharacter(pc);
}
} else if (levelUpIndicator.equals(actor)) {
UIManager.togglePerks(pc);
}
} else {
PlayerCharacterController controller = gameState.getPlayerCharacterController();
if (controller.isTargetSelectionInProgress()) {
Vector2 tempVector = MathUtil.getVector2();
boolean returnValue = controller.handleTargetSelection(Buttons.LEFT, pc.position().setVector2(tempVector));
MathUtil.freeVector2(tempVector);
return returnValue;
}
if (levelUpIndicator.equals(actor)) {
UIManager.togglePerks(pc);
return true;
}
if (!controller.isMultiSelectActive()) {
boolean wasSelected = pc.isSelected();
GameState.getPlayerCharacterGroup().selectOnlyMember(pc);
if (!wasSelected) {
pc.getAudioProfile().playCharacterBark(pc);
}
} else {
GameState.getPlayerCharacterGroup().toggleMemberSelection(pc);
}
}
return true;
}
项目:fabulae
文件:InventoryEventHandler.java
public boolean clicked (InputEvent inputEvent, Actor actor) {
if (actor instanceof Image) {
actor = ((Image)actor).getParent();
}
if (actor instanceof InventoryItemButton) {
InventoryItemButton clickedSlot = (InventoryItemButton)actor;
InventoryItem slotItem = clickedSlot.getItem();
InventoryItem draggedItem = UIManager.getDraggedItem();
InventoryContainer clickedContainer = clickedSlot.getInventory().getParentContainer();
boolean playersGroupItem = (draggedItem != null
&& draggedItem.isGroupHeldItem()
&& containerIsPlayerControlled(clickedContainer));
if (draggedItem != null && (slotItem == null || playersGroupItem)) {
putItemDown(clickedSlot, draggedItem, Buttons.RIGHT != inputEvent.getButton(), playersGroupItem);
return true;
} else if (slotItem != null && draggedItem == null) {
if (KeyBindings.MOVE_TO_JUNK.isPressed() && clickedContainer != GameState.getPlayerCharacterGroup()) {
moveToJunk(slotItem);
} else if (KeyBindings.MOVE_TO_INVENTORY.isPressed() && clickedContainer != displayedCharacter) {
moveToInventory(slotItem);
} else {
pickItemUp(clickedSlot, Buttons.RIGHT != inputEvent.getButton());
}
return true;
} else if (slotItem != null && draggedItem != null) {
if (Buttons.RIGHT == inputEvent.getButton() && draggedItem.isStackable(slotItem)) {
pickItemUp(clickedSlot, false);
} else {
swapOrCombineItems(clickedSlot, slotItem, draggedItem);
}
return true;
}
}
return false;
}