List of usage examples for com.badlogic.gdx.scenes.scene2d Touchable enabled
Touchable enabled
To view the source code for com.badlogic.gdx.scenes.scene2d Touchable enabled.
Click Source Link
From source file:ateamproject.kezuino.com.github.render.screens.LoginScreen.java
public LoginScreen(Game game) { super(game);//from w ww. j a va2 s . c o m TextField txtUsername = new TextField("pactales1@gmail.com", skin); TextField txtPassword = new TextField("pactales!", skin); txtPassword.setPasswordCharacter('*'); txtPassword.setPasswordMode(true); TextButton btnLogin = new TextButton("Inloggen", skin); btnLogin.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { btnLogin.setTouchable(Touchable.disabled); btnLogin.setText("Laden"); Thread loginThread = new Thread(() -> { PacketLoginAuthenticate packet = new PacketLoginAuthenticate(txtUsername.getText(), txtPassword.getText(), null); Client.getInstance().send(packet); Gdx.app.postRunnable(() -> { // Login was successful.. if (Client.getInstance().getId() != null) { PacketLoginUserExists packetUserExists = new PacketLoginUserExists( txtUsername.getText(), null); Client.getInstance().send(packetUserExists); // Handle user doesn't exist. if (!packetUserExists.getResult()) { Dialog d = new Dialog("Geen gebruiker gevonden", skin); d.add("Gebruikersnaam:"); TextField f = new TextField("", skin); d.add(f); bExit = new TextButton("Oke", skin); bExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!f.getText().isEmpty()) { PacketLoginCreateNewUser packet1; packet1 = new PacketLoginCreateNewUser(f.getText(), txtUsername.getText()); Client.getInstance().send(packet1); if (!packet1.getResult()) { new Dialog("Error", skin) { { text("De naam bestaat al."); button("Oke"); } }.show(stage); } else { d.hide(); Client.getInstance().setUsername(f.getText()); game.setScreen(new MainScreen(game)); } } } }); d.add(bExit); d.show(stage); } else { game.setScreen(new MainScreen(game)); } } else { new Dialog("Error", skin) { { text(packet.getResult().getMessage()); button("Oke"); } }.show(stage); } btnLogin.setText("Inloggen"); btnLogin.setTouchable(Touchable.enabled);//enable button touch }); }); loginThread.start(); } }); txtUsername.setSize(300, 40); txtPassword.setSize(300, 40); txtPassword.setPasswordMode(true); btnLogin.setSize(300, 40); btnLogin.setPosition(stage.getWidth() / 2 - btnLogin.getWidth() / 2, 150); txtUsername.setPosition(stage.getWidth() / 2 - txtUsername.getWidth() / 2, 300); txtPassword.setPosition(stage.getWidth() / 2 - txtPassword.getWidth() / 2, 250); stage.addActor(btnLogin); stage.addActor(txtUsername); stage.addActor(txtPassword); backgroundMusic = Assets.getMusicStream("menu.mp3"); }
From source file:awakening.view.menu.Controls.java
License:Apache License
/** * Set key to game' settings/*from w ww.j a va2 s. co m*/ * * @param b TextButton * @param key Key's Name * @param keyValue Key's value */ private void changeKey(TextButton b, String key, int keyValue) { if (b.equals(btnUp)) { btnUp.setText(key); game.setUpKey(key); game.setUp(keyValue); if (game.getLeft() == keyValue) { System.out.println(btnUp.getText()); System.out.println(b.getText()); btnLeft.setText("UNKNOWN"); game.setLeft(Input.Keys.UNKNOWN); game.setLeftKey("UNKNOWN"); } else if (game.getRight() == keyValue) { btnRight.setText("UNKNOWN"); game.setRight(Input.Keys.UNKNOWN); game.setRightKey("UNKNOWN"); } else if (game.getDown() == keyValue) { btnDown.setText("UNKNOWN"); game.setDown(Input.Keys.UNKNOWN); game.setDownKey("UNKNOWN"); } else if (game.getZoomIn() == keyValue) { btnZoomIn.setText("UNKNOWN"); game.setZoomIn(Input.Keys.UNKNOWN); game.setZoomInKey("UNKNOWN"); } else if (game.getZoomOut() == keyValue) { btnZoomOut.setText("UNKNOWN"); game.setZoomOut(Input.Keys.UNKNOWN); game.setZoomOutKey("UNKNOWN"); } } else if (b.equals(btnDown)) { btnDown.setText(key); game.setDownKey(key); game.setDown(keyValue); if (game.getLeft() == keyValue) { btnLeft.setText("UNKNOWN"); game.setLeft(Input.Keys.UNKNOWN); game.setLeftKey("UNKNOWN"); } else if (game.getRight() == keyValue) { btnRight.setText("UNKNOWN"); game.setRight(Input.Keys.UNKNOWN); game.setRightKey("UNKNOWN"); } else if (game.getUp() == keyValue) { btnUp.setText("UNKNOWN"); game.setUp(Input.Keys.UNKNOWN); game.setUpKey("UNKNOWN"); } else if (game.getZoomIn() == keyValue) { btnZoomIn.setText("UNKNOWN"); game.setZoomIn(Input.Keys.UNKNOWN); game.setZoomInKey("UNKNOWN"); } else if (game.getZoomOut() == keyValue) { btnZoomOut.setText("UNKNOWN"); game.setZoomOut(Input.Keys.UNKNOWN); game.setZoomOutKey("UNKNOWN"); } } else if (b.equals(btnLeft)) { btnLeft.setText(key); game.setLeftKey(key); game.setLeft(keyValue); if (game.getUp() == keyValue) { btnUp.setText("UNKNOWN"); game.setUp(Input.Keys.UNKNOWN); game.setUpKey("UNKNOWN"); } else if (game.getRight() == keyValue) { btnRight.setText("UNKNOWN"); game.setRight(Input.Keys.UNKNOWN); game.setRightKey("UNKNOWN"); } else if (game.getDown() == keyValue) { btnDown.setText("UNKNOWN"); game.setDown(Input.Keys.UNKNOWN); game.setDownKey("UNKNOWN"); } else if (game.getZoomIn() == keyValue) { btnZoomIn.setText("UNKNOWN"); game.setZoomIn(Input.Keys.UNKNOWN); game.setZoomInKey("UNKNOWN"); } else if (game.getZoomOut() == keyValue) { btnZoomOut.setText("UNKNOWN"); game.setZoomOut(Input.Keys.UNKNOWN); game.setZoomOutKey("UNKNOWN"); } } else if (b.equals(btnRight)) { btnRight.setText(key); game.setRightKey(key); game.setRight(keyValue); if (game.getLeft() == keyValue) { btnLeft.setText("UNKNOWN"); game.setLeft(Input.Keys.UNKNOWN); game.setLeftKey("UNKNOWN"); } else if (game.getUp() == keyValue) { btnUp.setText("UNKNOWN"); game.setUp(Input.Keys.UNKNOWN); game.setUpKey("UNKNOWN"); } else if (game.getDown() == keyValue) { btnDown.setText("UNKNOWN"); game.setDown(Input.Keys.UNKNOWN); game.setDownKey("UNKNOWN"); } else if (game.getZoomIn() == keyValue) { btnZoomIn.setText("UNKNOWN"); game.setZoomIn(Input.Keys.UNKNOWN); game.setZoomInKey("UNKNOWN"); } else if (game.getZoomOut() == keyValue) { btnZoomOut.setText("UNKNOWN"); game.setZoomOut(Input.Keys.UNKNOWN); game.setZoomOutKey("UNKNOWN"); } } else if (b.equals(btnZoomIn)) { btnZoomIn.setText(key); game.setZoomInKey(key); game.setZoomIn(keyValue); if (game.getLeft() == keyValue) { btnLeft.setText("UNKNOWN"); game.setLeft(Input.Keys.UNKNOWN); game.setLeftKey("UNKNOWN"); } else if (game.getRight() == keyValue) { btnRight.setText("UNKNOWN"); game.setRight(Input.Keys.UNKNOWN); game.setRightKey("UNKNOWN"); } else if (game.getDown() == keyValue) { btnDown.setText("UNKNOWN"); game.setDown(Input.Keys.UNKNOWN); game.setDownKey("UNKNOWN"); } else if (game.getUp() == keyValue) { btnUp.setText("UNKNOWN"); game.setUp(Input.Keys.UNKNOWN); game.setUpKey("UNKNOWN"); } else if (game.getZoomOut() == keyValue) { btnZoomOut.setText("UNKNOWN"); game.setZoomOut(Input.Keys.UNKNOWN); game.setZoomOutKey("UNKNOWN"); } } else if (b.equals(btnZoomOut)) { btnZoomOut.setText(key); game.setZoomOutKey(key); game.setZoomOut(keyValue); if (game.getLeft() == keyValue) { btnLeft.setText("UNKNOWN"); game.setLeft(Input.Keys.UNKNOWN); game.setLeftKey("UNKNOWN"); } else if (game.getRight() == keyValue) { btnRight.setText("UNKNOWN"); game.setRight(Input.Keys.UNKNOWN); game.setRightKey("UNKNOWN"); } else if (game.getDown() == keyValue) { btnDown.setText("UNKNOWN"); game.setDown(Input.Keys.UNKNOWN); game.setDownKey("UNKNOWN"); } else if (game.getZoomIn() == keyValue) { btnZoomIn.setText("UNKNOWN"); game.setZoomIn(Input.Keys.UNKNOWN); game.setZoomInKey("UNKNOWN"); } else if (game.getUp() == keyValue) { btnUp.setText("UNKNOWN"); game.setUp(Input.Keys.UNKNOWN); game.setUpKey("UNKNOWN"); } } b.setChecked(false); btnUp.setTouchable(Touchable.enabled); btnDown.setTouchable(Touchable.enabled); btnLeft.setTouchable(Touchable.enabled); btnRight.setTouchable(Touchable.enabled); btnZoomIn.setTouchable(Touchable.enabled); btnZoomOut.setTouchable(Touchable.enabled); btnBack.setTouchable(Touchable.enabled); slbLangages.setTouchable(Touchable.enabled); btnUp.setColor(btnBack.getColor()); btnDown.setColor(btnBack.getColor()); btnLeft.setColor(btnBack.getColor()); btnRight.setColor(btnBack.getColor()); btnZoomIn.setColor(btnBack.getColor()); btnZoomOut.setColor(btnBack.getColor()); }
From source file:awakening.view.menu.MapSelection.java
License:Apache License
public void changeMap() { maps.get(indexMap).setVisible(true); maps.get(indexMap).setTouchable(Touchable.enabled); ; }
From source file:com.agateau.pixelwheels.racescreen.HudButton.java
License:Open Source License
/** * name is a string like "left" or "right" *///from w w w.j a v a 2s . c o m public HudButton(Assets assets, Hud hud, String name) { mHud = hud; mRegions[0] = assets.findRegion("hud-" + name); mRegions[1] = assets.findRegion("hud-" + name + "-down"); setTouchable(Touchable.enabled); mClickListener = new ClickListener(); addListener(mClickListener); }
From source file:com.agateau.ui.menu.SwitchMenuItem.java
License:Apache License
public SwitchMenuItem(Menu menu) { super();//from w w w.j av a 2s . c o m mFocusIndicator = new FocusIndicator(menu); setTouchable(Touchable.enabled); mFont = menu.getSkin().get("default-font", BitmapFont.class); mStyle = menu.getSkin().get(SwitchMenuItemStyle.class); setSize(mStyle.frame.getMinWidth() * 2, mStyle.frame.getMinHeight()); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { trigger(); } }); }
From source file:com.agateau.ui.menu.TabMenuItem.java
License:Apache License
public TabMenuItem(Menu menu) { mMenu = menu;/*w ww. j ava 2 s. c o m*/ mFocusIndicator = new FocusIndicator(menu); mFont = menu.getSkin().get("default-font", BitmapFont.class); mStyle = menu.getSkin().get(TabMenuItemStyle.class); setTouchable(Touchable.enabled); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { float tabRight = mStyle.framePadding; for (int idx = 0; idx < mPages.size; ++idx) { tabRight += mPages.get(idx).tabWidth; if (x < tabRight) { setCurrentTab(idx); return; } } } }); }
From source file:com.aia.hichef.ui.n.MyWindow.java
License:Apache License
public MyWindow(String title, WindowStyle style) { if (title == null) throw new IllegalArgumentException("title cannot be null."); this.title = title; setTouchable(Touchable.enabled); setClip(true);//from w ww . ja v a 2 s . c o m setStyle(style); setWidth(150); setHeight(150); setTitle(title); setHeight(100); buttonTable = new Table(); addActor(buttonTable); addCaptureListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { toFront(); return false; } }); addListener(new InputListener() { int edge; float startX, startY, lastX, lastY; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (button == 0) { int border = resizeBorder; float width = getWidth(), height = getHeight(); edge = 0; if (isResizable) { if (x < border) edge |= Align.left; if (x > width - border) edge |= Align.right; if (y < border) edge |= Align.bottom; if (y > height - border) edge |= Align.top; if (edge != 0) border += 25; if (x < border) edge |= Align.left; if (x > width - border) edge |= Align.right; if (y < border) edge |= Align.bottom; if (y > height - border) edge |= Align.top; } if (isMovable && edge == 0 && y <= height && y >= height - getPadTop() && x >= 0 && x <= width) edge = MOVE; dragging = edge != 0; startX = x; startY = y; lastX = x; lastY = y; } return edge != 0 || isModal; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { dragging = false; } public void touchDragged(InputEvent event, float x, float y, int pointer) { if (!dragging) return; float width = getWidth(), height = getHeight(); float windowX = getX(), windowY = getY(); float minWidth = getMinWidth(), maxWidth = getMaxWidth(); float minHeight = getMinHeight(), maxHeight = getMaxHeight(); Stage stage = getStage(); boolean clampPosition = keepWithinStage && getParent() == stage.getRoot(); if ((edge & MOVE) != 0) { float amountX = x - startX, amountY = y - startY; windowX += amountX; windowY += amountY; } if ((edge & Align.left) != 0) { float amountX = x - startX; if (width - amountX < minWidth) amountX = -(minWidth - width); if (clampPosition && windowX + amountX < 0) amountX = -windowX; width -= amountX; windowX += amountX; } if ((edge & Align.bottom) != 0) { float amountY = y - startY; if (height - amountY < minHeight) amountY = -(minHeight - height); if (clampPosition && windowY + amountY < 0) amountY = -windowY; height -= amountY; windowY += amountY; } if ((edge & Align.right) != 0) { float amountX = x - lastX; if (width + amountX < minWidth) amountX = minWidth - width; if (clampPosition && windowX + width + amountX > stage.getWidth()) amountX = stage.getWidth() - windowX - width; width += amountX; } if ((edge & Align.top) != 0) { float amountY = y - lastY; if (height + amountY < minHeight) amountY = minHeight - height; if (clampPosition && windowY + height + amountY > stage.getHeight()) amountY = stage.getHeight() - windowY - height; height += amountY; } lastX = x; lastY = y; setBounds(Math.round(windowX), Math.round(windowY), Math.round(width), Math.round(height)); } public boolean mouseMoved(InputEvent event, float x, float y) { return isModal; } public boolean scrolled(InputEvent event, float x, float y, int amount) { return isModal; } public boolean keyDown(InputEvent event, int keycode) { return isModal; } public boolean keyUp(InputEvent event, int keycode) { return isModal; } public boolean keyTyped(InputEvent event, char character) { return isModal; } }); }
From source file:com.aia.hichef.ui.n.MyWindow.java
License:Apache License
public Actor hit(float x, float y, boolean touchable) { Actor hit = super.hit(x, y, touchable); if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this; return hit;//from www . jav a2 s.co m }
From source file:com.badlogic.gdx.ai.tests.utils.scene2d.TabbedPane.java
License:Apache License
private void initialize() { setTouchable(Touchable.enabled); tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1;/* ww w. j a v a 2s. c om*/ // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack); add(t).colspan(3).expand().fill(); }
From source file:com.bagon.matchteam.mtx.game.AbstractGame.java
License:Apache License
/** * BETA method (Works fine, but need lots of test) <br> * Screen to screen transition, only works for Scene2D Stage based game, * actionCurrent is applied to current stage when it is completed * (Sequence), actionNext is applied to new screens stage as intro for next * screen//ww w .j a v a 2 s.c o m * <p> * * WARNING! Do not use dispose anywhere else for stage/screen, if dispose * true here * * @param currentScreen * the screen currently set * @param actionCurrent * Scene2D action to be applied to current screen stage * @param nextScreen * the next screen to be set * @param actionNext * Scene2D action to be applied to next screen stage * @param disposeScreen * dispose current screen after transition completed * */ public void setScreenWithTransition(final AbstractScreen currentScreen, final Action actionCurrent, final AbstractScreen nextScreen, final Action actionNext, final boolean disposeScreen) { // currentScreen.getStage().getRoot().setTouchable(Touchable.disabled); nextScreen.getStage().getRoot().setTouchable(Touchable.disabled); // previousScreenToDispose = currentScreen; if (actionCurrent != null && currentScreen != null) { currentScreen.getStage().addAction(Actions.sequence(actionCurrent, new Action() { @Override public boolean act(float delta) { if (actionNext != null) { setScreen(nextScreen); nextScreen.getStage().addAction(actionNext); nextScreen.getStage().getRoot().setTouchable(Touchable.enabled); isDisposeScreen = disposeScreen; } else { setScreen(nextScreen); nextScreen.getStage().getRoot().setTouchable(Touchable.enabled); isDisposeScreen = disposeScreen; } return true; } })); } else { if (actionNext != null) { setScreen(nextScreen); nextScreen.getStage().getRoot().setTouchable(Touchable.enabled); nextScreen.getStage().addAction(actionNext); isDisposeScreen = disposeScreen; } else { setScreen(nextScreen); nextScreen.getStage().getRoot().setTouchable(Touchable.enabled); isDisposeScreen = disposeScreen; } } }