public JoinServerAsGuestState() { Input.setContext(Contexts.get(Sps.Contexts.Non_Free), Client.get().getFirstPlayerIndex()); stage = new Stage(); Gdx.input.setInputProcessor(stage); Label.LabelStyle lblStyle = new Label.LabelStyle(Assets.get().font(), Color.WHITE); label = new Label("Server IP:", lblStyle); TextField.TextFieldStyle style = new TextField.TextFieldStyle(); style.font = Assets.get().font(); style.cursor = UiAssets.getNewCursor(); style.fontColor = Color.WHITE; style.background = UiAssets.getNewBtnBg(); ipIn = new TextField("", style); stage.setKeyboardFocus(ipIn); ipIn.addListener( new ChangeListener() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { ipIn.setBlinkTime(1); } }); Table table = new Table(); table.setFillParent(true); table.add(label); table.add(ipIn).minWidth(300); stage.addActor(table); }
public void create() { stage = new Stage(); Gdx.input.setInputProcessor(stage); root = new Table(); root.setFillParent(true); stage.addActor(root); skin = new Skin(Gdx.files.internal("data/uiskin.json")); Table labels = new Table(); root.add(new ScrollPane(labels, skin)).expand().fill(); root.row(); root.add(drawnLabel = new Label("", skin)); for (int i = 0; i < count; i++) { labels.add( new Label("Label: " + i, skin) { public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); drawn++; } }); labels.row(); } }
private void fillTable() { StyleHelper helper = StyleHelper.getInstance(); Table scrollTable = new Table(); ImageButton newProfile = new ImageButton( helper.getImageButtonStyle("widgets/icon-plus")); newProfile.addListener(new NewProfileClickListener()); scrollTable.defaults().width(500).height(100).space(10); scrollTable.padTop(30); for (Profile profile : profileController.getAllProfiles()) { TextButton profileButton = new TextButton(profile.getName(), helper.getTextButtonStyle()); scrollTable.add(profileButton); scrollTable.row(); profileButton.addListener(new ChangeProfileClickListener()); } scrollTable.add(newProfile); scrollTable.padBottom(15); ScrollPane scrollPane = new ScrollPane(scrollTable); table.add(scrollPane).expand().fill(); }
public void showShieldBuff() { final Image shieldBuff = new Image(AssetLoader.uiAtlas.findRegion("shield")); final Label shieldTime = new Label("60:00s", Skins.xSmallTxt); Stack shieldBuffStack = new Stack(); shieldBuffStack.add(shieldBuff); Table shieldTimeTbl = new Table(); shieldTimeTbl.add(shieldTime).expand().bottom().left().pad(3); shieldBuffStack.add(shieldTimeTbl); final Table shieldBuffTbl = new Table(); shieldBuffTbl.setTransform(true); shieldBuffTbl.setBounds(0, 0, Resize.getWidth(), Resize.getHeight()); shieldBuffTbl.add(shieldBuffStack).size(60, 60).expand().right().top().padTop(200).padRight(10); GdxGame.hud_stage.addActor(shieldBuffTbl); actionManager.addAction( repeat( GameData.shieldDuration(), sequence( delay(1f), run( new Runnable() { @Override public void run() { GameData.setShieldDuration(GameData.shieldDuration() - 1); if (GameData.shieldDuration() <= 0) { GameData.setVillageShield(false); shieldBuffTbl.remove(); } String timer = SEG2HOR(GameData.shieldDuration()); shieldTime.setText(timer + "s"); } })))); }
private Table makeGameFileRow(final FileHandle gameSaveFile) { GameSave towerData; try { towerData = GameSaveFactory.readMetadata(gameSaveFile.read()); } catch (Exception e) { Gdx.app.log(TAG, "Failed to parse file.", e); return null; } FileHandle imageFile = Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png"); Actor imageActor = null; if (imageFile.exists()) { try { imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top); } catch (Exception ignored) { imageActor = null; } } if (imageActor == null) { imageActor = FontManager.Default.makeLabel("No image."); } Table fileRow = new Table(); fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10)); fileRow.row(); fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center(); fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top(); fileRow.row().fillX(); fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2); return fileRow; }
@Override public void show() { super.show(); table = new Table(); table.setFillParent(true); TextButtonStyle bStyle = new TextButtonStyle(); bStyle.font = Cache.getFont(48); bStyle.fontColor = Color.LIGHT_GRAY; final TextButton buttonPlay = new TextButton("PLAY", bStyle); buttonPlay.pad(20); table.add(buttonPlay); table.row(); final TextButton buttonCredits = new TextButton("CREDITS", bStyle); buttonCredits.pad(20); table.add(buttonCredits); table.row(); final TextButton buttonExit = new TextButton("EXIT", bStyle); buttonExit.pad(20); table.add(buttonExit); table.pad(150, 0, 0, 0); getStage().addActor(table); buttonPlay.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onExit(new LevelSelect(getGame()), buttonPlay, buttonCredits, buttonExit); } }); buttonCredits.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onExit(new Credits(getGame()), buttonPlay, buttonCredits, buttonExit); } }); buttonExit.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonPlay, ActorAccessor.ALPHA, 1).target(1).start(getTweenManager()); Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonCredits, ActorAccessor.ALPHA, 1).target(1).delay(0.1f).start(getTweenManager()); Tween.set(buttonExit, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonExit, ActorAccessor.ALPHA, 1).target(1).delay(0.2f).start(getTweenManager()); Gdx.input.setInputProcessor(new InputMultiplexer(getStage(), new TouchDetector(this))); }
public void showSheepMessageButtons() { if (sheepGame.isLosing()) { setupLoseButtons(); } else if (sheepGame.isWinning()) { setupWinButtons(); } else if (sheepGame.lastMessage()) { bottomMenu.clearChildren(); TextButton start = new TextButton("Start Level", assetHolder.buttonStyle); start.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.removeSheepMessage(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(start) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); } else { bottomMenu.clearChildren(); TextButton next = new TextButton("Next", assetHolder.buttonStyle); next.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.removeSheepMessage(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(next) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); } }
private void doStars(float stars) { for (int star = 0; star < 3; star++) { if (stars > star) { starTable.add(new Image(skin.getDrawable("star-filled"))).width(20).height(15); } else { starTable.add(new Image(skin.getDrawable("star-unfilled"))).width(20).height(15); } } }
@Override public void show() { super.show(); // retrieve the default table actor Table table = super.getTable(); stage.clear(); // atlas = new TextureAtlas(Gdx.files.internal("assets/data/uiskin.atlas")); // skin = new Skin(Gdx.files.internal("assets/data/uiskin.json")); Label label = new Label("Jamkhed", getSkin()); Button bouton1 = new Button(getSkin()); bouton1.add("Start Game"); bouton1.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { game.setScreen(game.getStartGameScreen()); Gdx.app.log(Jamkhed.LOG, "Allez HOP ACTION"); } }); TextButton bouton2 = new TextButton("Options", getSkin()); bouton2.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { game.setScreen(new OptionsScreen(game)); Gdx.app.log(Jamkhed.LOG, "Allez HOP Options"); } }); Button bouton3 = new Button(getSkin()); bouton3.add("Hall Of Fame"); bouton3.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Gdx.app.log(Jamkhed.LOG, "Allez HOP Classement"); } }); table.add(label).spaceBottom(20); table.row(); table.add(bouton1).width(150).spaceBottom(10); table.row(); table.add(bouton2).width(150).spaceBottom(10); table.row(); table.add(bouton3).width(150); table.row(); stage.addActor(table); }
public void create() { stage = new Stage(); Gdx.input.setInputProcessor(stage); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); Label nameLabel = new Label("Name:", skin); TextField nameText = new TextField("", skin); Label addressLabel = new Label("Address:", skin); TextField addressText = new TextField("", skin); Table table = new Table(); stage.addActor(table); table.setSize(260, 195); table.setPosition(190, 142); // table.align(Align.right | Align.bottom); table.debug(); TextureRegion upRegion = skin.getRegion("default-slider-knob"); TextureRegion downRegion = skin.getRegion("default-slider-knob"); BitmapFont buttonFont = skin.getFont("default-font"); TextButton button = new TextButton("Button 1", skin); button.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("touchDown 1"); return false; } }); table.add(button); // table.setTouchable(Touchable.disabled); Table table2 = new Table(); stage.addActor(table2); table2.setFillParent(true); table2.bottom(); TextButton button2 = new TextButton("Button 2", skin); button2.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { System.out.println("2!"); } }); button2.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("touchDown 2"); return false; } }); table2.add(button2); }
private void updateScrollPane() { innerContainer.clear(); switch (screen) { case SCREEN_LICENSE: innerContainer.add(getLicenseWidget()).row(); break; case SCREEN_CREDITS: innerContainer.add(getCreditsWidget()).row(); break; } }
@Override public void show() { super.show(); // retrieve the custom skin for our 2D widgets Skin skin = super.getSkin(); // create the table actor and add it to the stage table = super.getTable(); table.setWidth(stage.getWidth()); table.setHeight(stage.getHeight()); table.pad(10).defaults().spaceBottom(10).space(5); table.row().fill().expandX(); AtlasRegion splashRegion = getAtlas().findRegion("splash-screen/menulogo"); Image logo = new Image(splashRegion); table.add(logo).fill(false); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton continueButton = new TextButton("Continue", skin); continueButton.setVisible(false); continueButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // game.setScreen( new StartGameScreen( game ) ); } }); table.add(continueButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton newGameButton = new TextButton("New game", skin); newGameButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // TODO: Move it back to char select screen // game.setScreen( new CharSelectScreen( game ) ); if (Unsealed.DEBUG) game.setScreen(new BattleScreen(game)); else game.setScreen(new SplashScreen(game)); } }); table.add(newGameButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); // TextButton optionsButton = new TextButton( "Options", skin ); // optionsButton.setDisabled(true); // optionsButton.addListener( new ClickListener() { // @Override // public void clicked(InputEvent event, float x, float y ) { // game.setScreen( new OptionsScreen( game ) ); // } // } ); // table.add(optionsButton).size( 300, 60 ).uniform().spaceBottom(10); }
public void addRetryButtons(Table table) { TextButton retry = new TextButton("Restart Level", assetHolder.buttonStyle); retry.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.retryLevel(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(retry) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); TextButton selectLevel = new TextButton("Main Menu", assetHolder.buttonStyle); selectLevel.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.toMainMenu(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(selectLevel) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); if (assetHolder.levelLoader.currentLevelHasHelp()) addHelpButton(table); }
/** Set up benchmark labels */ private void setUpBencmarks() { LabelStyle style = new LabelStyle(font, null); // labelResolution = new Label(getResolution(), style); labelRunTime = new Label(getRunTime(), style); labelFps = new Label(getFPS(), style); // table.add().row().left(); table.add(labelResolution).row().left(); table.add(labelRunTime).row().left(); table.add(labelFps).row().left(); table.add().left(); }
@Override protected void build(Controller controller) { widget = new Image(); ApplicationAssets assets = controller.getApplicationAssets(); Skin skin = assets.getSkin(); I18N i18n = assets.getI18N(); this.time = new TextField("", skin) { @Override public float getPrefWidth() { return IMAGE_WIDTH; } }; IconButton dup = new IconButton("copy24x24", skin); dup.setTooltip(i18n.m("frames.duplicate")); dup.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { timeline.duplicate(FrameWidget.this); } }); IconButton delete = new IconButton("recycle24x24", skin); delete.setTooltip(i18n.m("frames.delete")); delete.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { timeline.delete(FrameWidget.this); } }); top = new Table(); top.setVisible(false); top.add(dup).left(); top.add(delete).expandX().right(); getImage().setScaling(Scaling.fit); topCell = add().expandX().fillX(); row(); add(widget).height(IMAGE_HEIGHT).width(IMAGE_WIDTH); row(); add(time); }
@Override public void setUpInterface(Table table) { // TODO: Move this to the skin. ScrollPane.ScrollPaneStyle style = new ScrollPane.ScrollPaneStyle(); table.pad(20); Label header = new Label(game.getLocale().get("main.about"), game.getSkin(), "bold"); table.add(header).expandX().align(Align.center).height(80).row(); innerContainer = new Table(); ScrollPane scroll = new ScrollPane(innerContainer, style); table.add(scroll).expand().fill().align(Align.top).row(); innerContainer.defaults().fill().expand(); screen = SCREEN_CREDITS; updateScrollPane(); final TextButton changeButton = new TextButton(game.getLocale().get("about.license"), game.getSkin()); changeButton.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (screen == SCREEN_CREDITS) { screen = SCREEN_LICENSE; changeButton.setText(game.getLocale().get("about.credits")); updateScrollPane(); } else { screen = SCREEN_CREDITS; changeButton.setText(game.getLocale().get("about.license")); updateScrollPane(); } game.player.playSound(SoundPlayer.SoundCode.SELECT); event.cancel(); } }); Table buttonRow = new Table(); buttonRow.defaults().fill().expand().width(Value.maxWidth).space(10); buttonRow.add(changeButton); TextButton backButton = new TextButton(game.getLocale().get("core.back"), game.getSkin()); buttonRow.add(backButton).row(); backButton.addListener(new ScreenPopper(game)); table.add(buttonRow).expandX().fillX().height(60).padTop(20).align(Align.bottom).row(); }
public static Table setupScrollpane( float x, float y, float paneWidth, float paneHeight, ScrollPane target, Texture scrollButton) { ScrollPane.ScrollPaneStyle scrollPaneStyle = new ScrollPane.ScrollPaneStyle(); scrollPaneStyle.vScrollKnob = new TextureRegionDrawable(new TextureRegion(scrollButton)); target.setStyle(scrollPaneStyle); target.setFadeScrollBars(false); target.setOverscroll(false, false); target.setFlickScroll(false); target.addListener(new GetScrollFocusWhenEntered(target)); Table scenarioPaneContainer = new Table(); scenarioPaneContainer.setX(x); scenarioPaneContainer.setY(y); scenarioPaneContainer.setWidth(paneWidth); scenarioPaneContainer.setHeight(paneHeight); scenarioPaneContainer.add(target).fill().expand(); return scenarioPaneContainer; }
@Override public void show() { stage = new Stage(); Gdx.input.setInputProcessor(stage); atlas = new TextureAtlas("button.pack"); skin = new Skin(atlas); table = new Table(skin); table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // table.background(new TextureRegionDrawable(new TextureRegion("Splash.png"))); // creating font white = new BitmapFont(Gdx.files.internal("font.fnt"), false); // creating buttons TextButtonStyle buttonStyle = new TextButtonStyle(); buttonStyle.up = skin.getDrawable("button.up"); buttonStyle.down = skin.getDrawable("button.down"); buttonStyle.pressedOffsetX = 1; buttonStyle.pressedOffsetY = -1; buttonStyle.font = white; buttonStart = new TextButton("START", buttonStyle); buttonStart.pad(10); table.add(buttonStart); stage.addActor(table); }
public PropertyTable(Skin skin) { // super(skin); table = new Table(skin); this.skin = skin; top().left(); table.top().left(); table.add(new Label("Name", skin)); table.add(new Label("Value", skin)); table.setFillParent(true); fill(); prefHeight(1000); setActor(table); }
public Option() { selection_ = StateMEnuEnum.OPTION; values_ = GlobalValues.getInstance(); // creation zone affichage du menu stage = new Stage(new ScreenViewport()); // boutons et label layout_table = new Table(); layout_table.setSize(values_.get_width(), values_.get_width()); retour_ = new TextButton("Retour", values_.get_Skin()); // init du bouton retour retour_.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selection_ = StateMEnuEnum.MENU; } }); layout_table.add(retour_).width(values_.get_width()).pad(10); stage.addActor(layout_table); // Gdx.input.setInputProcessor(stage); }
private void buildTutorialDialog(String animationPath) { AssetManager manager = AssetManager.getInstance(); StyleHelper helper = StyleHelper.getInstance(); final Dialog tutorial = new Dialog("", StyleHelper.getInstance() .getDialogStyle()); tutorial.clear(); tutorial.fadeDuration = 0f; Table buttonTable = new Table(); Drawable drawable = new TextureRegionDrawable(new TextureRegion( manager.get(animationPath, Texture.class))); // used image button here because it keeps the ratio of the texture ImageButton tutorialImage = new ImageButton(drawable); ImageButton okay = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-check")); okay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { tutorial.hide(); } }); buttonTable.add(okay).size(100).bottom().right().expand().pad(30); tutorial.stack(tutorialImage, buttonTable).height(500).width(800); tutorial.show(stage); }
public PlayerManagement(Player pc) { batch = new SpriteBatch(); stage = new Stage(new ScreenViewport()); // stage.toScreenCoordinates(coords, transformMatrix) Gdx.input.setInputProcessor(stage); pixmap = new Pixmap(Vals.SCREEN_WIDTH, Vals.SCREEN_HEIGHT, Pixmap.Format.RGBA8888); // Equipment and Stats pixmap.setColor(Color.BLUE); pixmap.fillRectangle( Vals.GRID_HALF, Vals.GRID_HALF, Vals.SCREEN_WIDTH / 2 - Vals.GRID_HALF, Vals.SCREEN_HEIGHT / 2 - Vals.GRID_SIZE); // Inventory and item descriptions pixmap.setColor(Color.WHITE); pixmap.fillRectangle( Vals.GRID_HALF, Vals.SCREEN_HEIGHT / 2, Vals.SCREEN_WIDTH / 2 - Vals.GRID_SIZE * 6, Vals.SCREEN_HEIGHT / 2 - Vals.GRID_SIZE); pixmap.setColor(Color.GRAY); pixmap.fillRectangle( Vals.GRID_HALF + Vals.SCREEN_WIDTH / 2 - Vals.GRID_SIZE * 6, Vals.SCREEN_HEIGHT / 2, Vals.GRID_SIZE * 6 - Vals.GRID_HALF, Vals.SCREEN_HEIGHT / 2 - Vals.GRID_SIZE); texture = new Texture(pixmap); Table table = new Table(); for (Item item : pc.inventory) { table.add(new ItemWidget(item)); } ScrollPane inventoryView = new ScrollPane(table); stage.addActor(inventoryView); }
public void setupWinButtons() { bottomMenu.clearChildren(); if (assetHolder.levelLoader.areMoveLevels()) { TextButton nextLevel = new TextButton("Next Level", assetHolder.buttonStyle); nextLevel.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.nextLevel(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(nextLevel) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); bottomMenu.row(); } addRetryButtons(bottomMenu); }
public IntroScreen(final DirectedGame game) { super(game); rootTable = new Table(); rootTable.setFillParent(true); final Actor logo = new Image(Assets.assetsManager.get(Assets.HEADMADE_LOGO, Texture.class)); // logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2); // logo.scaleBy(2f); logo.setColor(Color.BLACK); rootTable.add(logo).center().expand(); rootTable.row(); // rootTable.setDebug(true); this.stage.addActor(rootTable); stage.addListener( new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.ESCAPE) { Gdx.app.exit(); return true; } return super.keyDown(event, keycode); } }); Assets.instance.loadAll(); }
public void addResumeButton(Table table) { TextButton resume = new TextButton("Resume", assetHolder.buttonStyle); resume.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(resume) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); }
public void addProperty(String name, String value, Types type) { table.row(); table.add(new Label(name, skin)).expandX().left(); if (type == Types.BOOLEAN) { SelectBox<String> sb = new SelectBox<String>(skin); sb.setItems(BOOLEAN_VALUES); if (value != null) sb.setSelected(value); sb.setName(name); table.add(sb).expandX().left(); sb.addListener( new ChangeListener() { @SuppressWarnings("unchecked") @Override public void changed(ChangeEvent event, Actor actor) { updateModel(actor.getName(), ((SelectBox<String>) actor).getSelected()); } }); } else { TextField tf = new TextField(value == null ? "" : value, skin); tf.setName(name); table.add(tf).expandX().left(); if (type == Types.INTEGER) tf.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); tf.setTextFieldListener( new TextFieldListener() { @Override public void keyTyped(TextField actor, char c) { updateModel(actor.getName(), ((TextField) actor).getText()); } }); // tf.addListener(new FocusListener() { // // @Override // public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) { // if(!focused) // updateModel(actor.getName(), ((TextField)actor).getText()); // } // }); } }
private Table buildBackgoundLayer() { Table layer = new Table(); imgBackgound = new Image(skinCanyonBunny, "map"); imgBackgound.setScale(Constants.SCALE); layer.add(imgBackgound); imgBackgound.setColor( imgBackgound.getColor().r, imgBackgound.getColor().g, imgBackgound.getColor().b, 0.2f); return layer; }
public Quitter() { selection_ = StateMEnuEnum.QUITTER; values_ = GlobalValues.getInstance(); skin_bouton = values_.get_Skin(); layout_table = new Table(); layout_table.setSize(values_.get_width(), values_.get_width()); // creation zone affichage du menu stage = new Stage(new ScreenViewport()); // boutons et label oui_bouton = new TextButton("Oui", skin_bouton); // init du bouton Jeu non_bouton = new TextButton("Non", skin_bouton); // init du bouton Option label_quitter = new Label("Voulez vous quitter?", skin_bouton); // création des listenners oui_bouton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); non_bouton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selection_ = StateMEnuEnum.MENU; } }); // placement des boutons layout_table.add(label_quitter).width(values_.get_width()).pad(10); layout_table.row(); layout_table.add(oui_bouton).width(values_.get_width()).pad(10); layout_table.row(); layout_table.add(non_bouton).width(values_.get_width()).pad(10); stage.addActor(layout_table); // activation de la zone // Gdx.input.setInputProcessor(stage); }
public void chatWindow() { chatSend.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Label label = new Label(validate(chatInput.getText()), skin); label.setWrap(false); System.err.println(label.getText()); cont.add(label); // msg.add(validate(chatInput.getText())); } }); table.row(); table.add(chatInput); table.add(chatSend); table.row(); }
public Hud(SpriteBatch sb) { // define our tracking variables worldTimer = 300; timeCount = 0; score = 0; // setup the HUD viewport using a new camera seperate from our gamecam // define our stage using that viewport and our games spritebatch viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera()); stage = new Stage(viewport, sb); // define a table used to organize our hud's labels Table table = new Table(); // Top-Align table table.top(); // make the table fill the entire stage table.setFillParent(true); // define our labels using the String, and a Label style consisting of a font and color countdownLabel = new Label( String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); scoreLabel = new Label( String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); // add our labels to our table, padding the top, and giving them all equal width with expandX table.add(marioLabel).expandX().padTop(10); table.add(worldLabel).expandX().padTop(10); table.add(timeLabel).expandX().padTop(10); // add a second row to our table table.row(); table.add(scoreLabel).expandX(); table.add(levelLabel).expandX(); table.add(countdownLabel).expandX(); // add our table to the stage stage.addActor(table); }