@Override public void create () { camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); stage = new Stage(); stage.addListener(new InputListener(){ @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){ stage.getActors().get(counter).addAction(Actions.moveTo(x-50,y-50,1)); counter++; if(counter==stage.getActors().size) { counter=0; } return true; } }); Gdx.input.setInputProcessor(stage); }
public void addTouchListener() { this.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (isHighlighted()) { setHighlighted(false); } else { setHighlighted(true); } event.stop(); return true; } }); }
@Override public void show() { player = new Player(Assets.random()); client = new Client(player); stage = new Stage(); Image logo = new Image(Assets.LOGO); logo.setPosition((Gdx.graphics.getWidth() - logo.getWidth()) / 2, Gdx.graphics.getHeight() * 0.85f); Image shadow = dropShadow(logo); stage.addActor(logo); stage.addActor(shadow); stage.addActor(new PlayGroup(client)); stage.getRoot().addCaptureListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (!(event.getTarget() instanceof TextField)) stage.setKeyboardFocus(null); return true; } }); Gdx.input.setInputProcessor(stage); }
public TabSelector(final int slotNum, Texture[] icons, final boolean isVertical, int defaultSlot) { if(slotNum != icons.length) throw new IllegalArgumentException("Icon array length needs to equal slot quantity"); setTouchable(Touchable.enabled); slot = defaultSlot; this.slotNum = slotNum; this.isVertical = isVertical; this.icons = icons; selection = new Texture("theme/basic/ui/SelectionBox.png"); addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if(isVertical) slot = (int)(y / (getHeight() / slotNum)); else slot = (int)(x / (getWidth() / slotNum)); return true; } }); }
public void initButtons(int score,TextureAtlas buttonAtlas) { Skin buttonSkin = new Skin(); buttonSkin.addRegions(buttonAtlas); //TODO FIX THIS SHIT INDENTATION //TODO Long-term fix the magic numbers ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"), buttonSkin.getDrawable("playbutton")); playButton.setSize(256, 64); playButton.setPosition(screenSize.width/2-playButton.getWidth()/2, screenSize.height/2-playButton.getHeight()/2+50); playButton.addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { polymorph.setScreen(new GameScreen(polymorph)); DeathScreenMusic.stop(); return true; } }); stage.addActor(playButton); }
private void config_loading_stage() { // TODO Auto-generated method stub loading_stage = new Stage(managment_viewport, batch); loading_stage.addActor(logo_actor); loading_stage.addActor(loading_background_actor); loading_stage.addActor(loading_actor); loading_stage.addListener(new InputListener(){ @Override public boolean keyDown(InputEvent event, int keycode) { // TODO Auto-generated method stub if(keycode == Keys.BACK){ back_button_down(); } return true; } }); }
private void addPreviewProperties(Table bottom, InputListener scrollPaneListener) { Label label = new Label("Preview Properties", getSkin(), "title"); bottom.add(label); bottom.row(); previewPropertiesTable = new Table(); previewPropertiesTable.defaults().pad(5.0f); ScrollPane scrollPane = new ScrollPane(previewPropertiesTable, getSkin()); scrollPane.setFadeScrollBars(false); scrollPane.setFlickScroll(false); scrollPane.addListener(scrollPaneListener); bottom.add(scrollPane).grow().padTop(10.0f).padBottom(10.0f); refreshPreviewProperties(); }
public RecipeButton(final ItemEnum.Tower tower) { super(GDefence.getInstance().assetLoader.generateImageButtonSkin(tower.getTowerTexture())); // System.out.println(tower.getTowerTexture().getMinFilter() + " " + tower.getTowerTexture().getMagFilter()); // this.tower = tower; towerRecipe = new Recipe(tower); tooltip = new RecipeTooltip(towerRecipe, GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class)); tooltip.setLocked(true); // tooltip.setVisible(false); updateType(); addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if(type != User.RecipeType.locked && tower != ItemEnum.Tower.Basic){ if(GDefence.getInstance().user.deleteGold(towerRecipe.getGlobalCost())){ GDefence.getInstance().user.buyTowerRecipe(tower); owner.updateTypes();//if owner != null } } return true; } }); addListener(new TooltipListener(tooltip, true)); }
public BackButton(boolean ownPosition) { super(GDefence.getInstance().assetLoader.getBackButtonSkin()); //super(mainClass.getSkin()); int backButtonsSize[] = {64, 64}; setSize(backButtonsSize[0], backButtonsSize[1]); if(ownPosition) { setPosition(10, Gdx.graphics.getHeight() - backButtonsSize[1]); } addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { //mainClass.setScreen(new MainMenu(mainClass)); GDefence.getInstance().setPreviousScreen(); return true; } }); }
private void load(){ tooltip = new LevelTooltip(this, GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class)); tooltip.setTouchable(Touchable.disabled); //CampainMap.getStage().addActor(tooltip); // GDefence.getInstance().getCampainMap().getStage().addActor(tooltip); addListener(new TooltipListener(tooltip, true)); addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (!isLocked()) { GDefence.getInstance().getLevelPreparationScreen().setLevel(number); GDefence.getInstance().switchScreen(GDefence.getInstance().getLevelPreparationScreen()); } return true; } }); }
@Override public final void start(final Callback callback) { final Actor target = getTargetActor(); stage = target.getStage(); if (stage == null) throw new IllegalStateException("actor not on stage!"); listener = new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (!event.getTarget().isDescendantOf(target)) { event.cancel(); return false; } return true; } }; stage.addCaptureListener(listener); resources.put("allowTouchDownTo", listener); callback.taskEnded(); }
@Override public void start(Callback callback) { Stage stage = resources.get("stage"); InputListener listener = new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { if (keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) { event.cancel(); return true; } return super.keyDown(event, keycode); } }; stage.addCaptureListener(listener); resources.put("restrictBackButton", listener); callback.taskEnded(); }
public DialoguePanel(DialoguePanelStyle style) { super(style); this.style = style; pcTalkTable = new Table(); addListener(new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { int numberPressed = KeyBindings.getNumberPressed(keycode); if (numberPressed < 1 || numberPressed > pcTalkTable.getCells().size) { return false; } Actor actor = pcTalkTable.getCells().get(numberPressed-1).getActor(); pcTalkSelected(actor.getName()); return true; } }); }
/** * @param path - the path to the skin */ public RavUI (String path) { if (!VisUI.isLoaded()) if(path.length() > 0) VisUI.load(path); else VisUI.load(); screenStage = new Stage(new ScreenViewport()); debugConsole = new DebugConsole(); RavTech.input.addInputProcessor(screenStage); screenStage.addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int key) { if (key == Keys.F1) debugConsole.toggleVisible(); return true; } }); screenStage.addActor(debugConsole); }
public Map() { mapView = new MapView(); terrainObservers = new Array<IMapObserver>(); setX(0f); setY(0f); setWidth(rows * square); setHeight(cols * square); addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { for (IMapObserver observer : terrainObservers) { observer.terrainClicked((int)x, (int)y); } return true; } }); }
public BallActor(BoardActor board, Ball ball, TextureAtlas atlas) { this.board = board; this.ball = ball; this.atlas = atlas; setScaling(Scaling.fit); addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { setSelected(!isSelected()); return true; } }); grayDrawable = new TextureRegionDrawable(atlas.findRegion("ball_gray")); colorDrawables = new HashMap<>(); for (BallColor color : BallColor.values()) { colorDrawables.put(color, new TextureRegionDrawable(atlas.findRegion("ball_" + color.toString().toLowerCase()))); } }
public List (ListStyle style) { selection.setActor(this); selection.setRequired(true); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (pointer == 0 && button != 0) return false; if (selection.isDisabled()) return false; List.this.touchDown(y); return true; } }); }
public LoginGamesScreen(Viewport viewport, SpriteBatch batch) { super(viewport, batch); TextureRegion backgroundTexture = new TextureRegion(Resources.assets.get("background.png", Texture.class)); background = new Background(backgroundTexture); reconnectButton = Resources.reconnectButton; teacherGames = new GamesOpenActor(Resources.skin); enterGame = false; stage.addActor(background); stage.addActor(teacherGames); stage.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if(keycode == Keys.BACK || keycode == Keys.ESCAPE) { AppMain.setNewScreen(AppMain.loginScreen); } return true; } }); }
public LoginScreen(Viewport viewport, SpriteBatch batch) { super(viewport, batch); TextureRegion backgroundTexture = new TextureRegion(Resources.assets.get("background.png", Texture.class)); changeScreen = false; background = new Background(backgroundTexture); reconnectButton = Resources.reconnectButton; loginActor = new LoginActor(Resources.skin); logo = new Title(); stage.addActor(background); stage.addActor(loginActor); stage.addActor(logo); stage.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if(keycode == Keys.BACK || keycode == Keys.ESCAPE) { Resources.exitDialog.show(stage); } return true; } }); }
public TeacherLoginRegisterScreen(Viewport viewport, SpriteBatch batch) { super(viewport, batch); TextureRegion backgroundTexture = new TextureRegion(Resources.assets.get("background.png", Texture.class)); background = new Background(backgroundTexture); logo = new Title(); teacherLoginRegisterActor = new TeacherLoginRegisterActor(Resources.skin); exitDialog = new ExitDialogApp(Resources.skin); reconnectButton = Resources.reconnectButton; stage.addActor(background); stage.addActor(logo); stage.addActor(teacherLoginRegisterActor); stage.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if(keycode == Keys.BACK || keycode == Keys.ESCAPE) { exitDialog.show(stage); } return true; } }); }
public PopOver() { triangle = texture(TowerAssetManager.WHITE_SWATCH_TRIANGLE); swatch = texture(TowerAssetManager.WHITE_SWATCH); background = TowerAssetManager.texture("hud/window-bg.png"); background.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); content = new Table(); content.defaults().top().left().space(Display.devicePixel(6)); setTouchable(Touchable.enabled); addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } }); }
/** * Konstruktor. */ public NavbarStableButton() { ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.HOME); this.addActor(imageButton); this.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { Gdx.app.log("Settings Button", "Settings BUTTON CLick"); GameManagerFactory.getInstance().navigateToLevel("playerMenu"); return true; }; }); this.setWidth(imageButton.getHeight()); }
/** * Konstruktor. */ public NavbarCityInfoButton() { ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.INFO); this.addActor(imageButton); this.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { clicked(); return true; }; }); this.setWidth(imageButton.getHeight()); }
/** * Konstruktor. */ public NavbarSettingsButton() { ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.SETTINGS); this.addActor(imageButton); this.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { getNavigationBar().getOverlay().showPopup(new SettingsPopup()); Gdx.app.log("Settings Button", "Settings BUTTON CLick"); return true; }; }); this.setWidth(imageButton.getHeight()); }
/** * Konstruktor. */ public NavbarLootGalleryButton() { ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.LOOT); this.addActor(imageButton); this.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { GameManager gm = GameManagerFactory.getInstance(); if (gm.getCurrentLevelID() != "lootGallery") { gm.navigateToLevel("lootGallery"); } return true; }; }); this.setWidth(imageButton.getHeight()); }
/** * Konstruktor. */ public NavbarPauseButton() { ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.PAUSE); this.setWidth(imageButton.getHeight()); this.addActor(imageButton); this.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { Gdx.app.log("PAUSE Button", "PAUSE BUTTON CLick"); NavBar navBar = NavbarPauseButton.this.getNavigationBar(); Popup p = new GamePausePopup(); Overlay overlay = navBar.getOverlay(); overlay.getLevel().pause(); overlay.showPopup(p); return true; }; }); }
/** * Initalisierung des standart backgrounds. */ private void createBackgroundImage() { backgroundImage = new Image(new TextureRegionDrawable(AssetManager.getTextureRegion("ui", "panel_beige"))); backgroundImage.setWidth(popupWidth); // backgroundImage.setHeight(popupHeight); // backgroundImage.setY((height / 2) - popupHeight / 2); backgroundImage.addListener(new InputListener() { @Override public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer, final int button) { event.cancel(); return true; } }); content.addActor(backgroundImage); }
ItemSlot(final int index) { this.index = index; addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (selectedIndex != -1) { if (selectedIndex != index) { selectedIndex = index; return true; } } if (swapItem != null) { swapItem.stackTo(inventory.getItem(index)); } return true; } }); }
public static void setUp(){ String ppath = System.getProperty("user.dir"); androidDir = ppath.replace("\\", "/").replace(MyGame.GAME_NAME, MyGame.GAME_NAME+"-android"); androidDir += "/market/"; BaseScreen.getStage().addListener(new InputListener(){ @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.ENTER){ try { saveScreenshot(); } catch (IOException e) { e.printStackTrace(); } } else if (keycode == Keys.SPACE){ copyDescription(); } return true; } }); }
public BaseScreen() { this.stage = new Stage(new ScreenViewport()); Gdx.input.setInputProcessor(this.stage); this.stage.addListener(new InputListener(){ @Override public boolean keyDown(InputEvent event, int keycode) { if((keycode == Keys.BACK) || (keycode == Keys.ESCAPE)) { BaseScreen.this.backButtonPressed(); } if(keycode == Keys.ENTER) { BaseScreen.this.enterButtonPressed(); } return super.keyDown(event, keycode); } }); }
public CustomList(CustomListStyle style, CellRenderer<T> r) { selection = new ArraySelection<T>(items); selection.setActor(this); selection.setRequired(true); cellRenderer = r; setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (pointer == 0 && button != 0) return false; if (selection.isDisabled()) return false; CustomList.this.touchDown(y); return true; } }); }
public static void setConsole(Console console) { EditorLogger.console = console; EditorLogger.console.setDisplayKeyID(Keys.F1); console.setMaxEntries(1000); final Stage s = (Stage) console.getInputProcessor(); final Actor actor = s.getActors().items[0]; actor.addListener(new InputListener() { @Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { if (toActor == null) { s.setScrollFocus(null); } } }); console.setCommandExecutor(new EditorCommandExecutor()); }
/** * Dialog with given text and single OK button. * @param title dialog title */ public static VisDialog showOKDialog (Stage stage, String title, String text) { final VisDialog dialog = new VisDialog(title); dialog.closeOnEscape(); dialog.text(text); dialog.button(ButtonType.OK.getText()).padBottom(3); dialog.pack(); dialog.centerWindow(); dialog.addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.ENTER) { dialog.fadeOut(); return true; } return false; } }); stage.addActor(dialog.fadeIn()); return dialog; }
public VisCheckBox (String text, VisCheckBoxStyle style) { super(text, style); clearChildren(); bgImage = new Image(style.checkBackground); tickImage = new Image(style.tick); imageStackCell = add(imageStack = new Stack(bgImage, tickImage)); Label label = getLabel(); add(label).padLeft(5); label.setAlignment(Align.left); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisCheckBox.this); return false; } }); }
private void init (String text) { defaults().space(3); image = new Image(); image.setScaling(Scaling.fit); add(image); label = new Label(text, new LabelStyle(style.font, style.fontColor)); label.setAlignment(Align.center); add(label); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageTextButton.this); return false; } }); }
private void init () { image = new Image(); image.setScaling(Scaling.fit); add(image); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageButton.this); return false; } }); updateImage(); }
public Screen(GlxyGame gm) { game = gm; stage = new Stage(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); table = new Table(); table.setFillParent(true); stage.addActor(table); Gdx.input.setInputProcessor(stage); stage.addListener(new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { onKeyUp(keycode); return false; } }); initViewport(); }
protected LinearLayout buildSearchButton() { LinearLayout searchActor = new LinearLayout(true); IconButton icon = WidgetBuilder.toolbarIcon(SkinConstants.IC_SEARCH, i18N.m("search")); search = new TextField("", skin); search.addListener(new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { if (keycode == Input.Keys.ENTER) { loadContents(); return true; } return false; } }); searchActor.add(icon); searchActor.add(search).marginRight(WidgetBuilder.dpToPixels(16)); return searchActor; }
private void registerShortcuts() { final ShortcutsMap shortcutsMap = controller.getShortcutsMap(); stage.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { return !event.isHandled() && shortcutsMap.shortcut(keycode); } }); shortcutsMap.registerShortcutCtrl(Keys.O, OpenGame.class); shortcutsMap.registerShortcutCtrl(Keys.S, Save.class); shortcutsMap.registerShortcutCtrl(Keys.X, Cut.class); shortcutsMap.registerShortcutCtrl(Keys.C, Copy.class); shortcutsMap.registerShortcutCtrl(Keys.V, Paste.class); shortcutsMap.registerShortcutCtrl(Keys.Z, Undo.class); shortcutsMap.registerShortcutCtrl(Keys.Y, Redo.class); shortcutsMap.registerShortcutKey(Keys.BACKSPACE, Back.class); shortcutsMap.registerShortcutAlt(Keys.BACKSPACE, Next.class); }
@Override public AbstractWidget createWidget(Controller controller) { setFillWindow(true); Skin skin = controller.getApplicationAssets().getSkin(); drawable = skin.getDrawable("blank"); final GroupEditor container = new GroupEditor( controller.getShapeRenderer(), new GroupEditorConfiguration()); container.setBackground(skin.getDrawable("blank")); final Group root = new Group(); container.setRootGroup(root); container.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.A) { Actor a = new RectangleActor(); root.addActor(a); } return true; } }); return container; }