public void showConfig(Tile tile){ configTile = tile; table.clear(); tile.block().buildTable(tile, table); table.pack(); table.setTransform(true); table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true), Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); table.update(()->{ table.setOrigin(Align.center); Vector2 pos = Graphics.screen(tile.worldx() + tile.block().getPlaceOffset().x, tile.worldy() + tile.block().getPlaceOffset().y); table.setPosition(pos.x, pos.y, Align.center); if(configTile == null || configTile.block() == Blocks.air){ hideConfig(); } }); }
private void initPreView(int[] nines) { previewTable.clear(); previewWidget = new PreviewWidget(); previewWidget.setHeight(205); previewTable.add(previewWidget).width(200).height(205).top(); previewTable.row(); previewWidget.update(texture, nines); VisLabel label = new VisLabel("Note: after saving, your \n scene will reload to \n apply changes."); label.setAlignment(Align.center); previewTable.add(label).pad(10).fillY().expandY(); previewTable.row(); saveBtn = new VisTextButton("apply and save"); previewTable.add(saveBtn).pad(5); previewTable.row(); }
/** * Loading stage * @param doLoad should resources be loaded? It acts as a splash screen otherwise. */ public StageLoad(boolean doLoad) { this.doLoad = doLoad; // Create icon icon = new Image(new Texture("image/icon-512.png")); int size = Gdx.graphics.getHeight(); if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth()) size = Gdx.graphics.getWidth(); icon.setSize(size, size); icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2, Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2); addActor(icon); // Loading Text Label.LabelStyle loadingStyle = new Label.LabelStyle(); loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt")); loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720); loading = new Label("DRC Sim", loadingStyle); loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f); loading.setAlignment(Align.center); addActor(loading); }
/** * Zeigt die Credits an. * * @param camera die aktuelle Kamera * @param deltaTime die vergangene Zeit seit dem letztem Frame */ @Override public void render(OrthographicCamera camera, float deltaTime) { batch.setProjectionMatrix(camera.combined); batch.begin(); fontLayout.setText(font, "ESC", Color.DARK_GRAY, 50, Align.left, false); font.draw(batch, fontLayout, -camera.viewportWidth / 2 + 5, camera.viewportHeight / 2 - 10); int y = (int) camera.viewportHeight / 2 - 35 + (int)offset; for (CreditLine line: creditLines) { fontLayout.setText(font, line.getLine(), line.getColor(), camera.viewportWidth, Align.center, false); font.draw(batch, fontLayout, -camera.viewportWidth / 2, y); y -= FONT_HEIGHT; } batch.end(); }
public Troop(int troops, GraphPath<Tile> path) { this.troops = troops; this.path = new DefaultGraphPath<>(); for (Tile tile : path) { this.path.add(tile); } texture = Assets.TROOP; setSize(texture.getRegionWidth(), texture.getRegionHeight()); label = new ConquestLabel(this.troops, getX(), getY(), getWidth(), getHeight()); setOrigin(Align.center); createActions(); }
public BuildingScoreDialog(Hexpert hexpert, Skin skin) { super(hexpert, skin, false); getContentTable().defaults().pad(15); Label.LabelStyle lblStyle = skin.get("bigger", Label.LabelStyle.class); Label lblExplaination = new Label(hexpert.i18NBundle.get("tut_score"), skin); lblExplaination.setWrap(true); lblExplaination.setAlignment(Align.center); getContentTable().add(lblExplaination).colspan(8).width(8*160); lblExplaination.setWrap(true); getContentTable().row(); for (int i = 1; i < BuildingType.values().length; i++) { BuildingType buildingType = BuildingType.values()[i]; Image image = new Image(new TextureRegion((Texture) hexpert.assetManager.get(SPRITE_FOLDER + buildingType.name().toLowerCase() + "_min.png"))); getContentTable().add(image).width(160).height(160); Label lblScore = new Label(Integer.toString(buildingType.getScore()), lblStyle); lblScore.setAlignment(Align.center); getContentTable().add(lblScore).expand(); if (i % 4 == 0) getContentTable().row(); } }
public void _init(Drawable[] textures, int depth, Vector2[] bias) { if (bias != null && bias.length != textures.length) throw new IllegalArgumentException(); group = new Group(); images = new Image[textures.length]; for (int i=0; i<textures.length; i++) { Drawable texture = textures[i]; Image image = new Image(texture); images[i] = image; image.setBounds(0, 0, texture.getMinWidth(), texture.getMinHeight()); if (bias != null) image.setPosition(bias[i].x, bias[i].y, Align.center); else image.setPosition(0, 0, Align.center); group.addActor(image); } mDepth = depth; biases = bias; }
public MessageWindow(String message, BitmapFont font, float width, float height) { setTouchable(Touchable.enabled); setBounds(width / 2 - width / 4, height / 2 - height / 10, width / 2, height / 5); texture = new Texture("theme/basic/ui/Window.png"); this.message = message; table = new Table(); table.setSize(getWidth(), getHeight()); table.align(Align.center | Align.top); table.setPosition(getX(), getY()); Label label = new Label(message, new Label.LabelStyle(font, Color.BLACK)); label.setWrap(true); label.setFontScale(0.7f); Label label2 = new Label("Tap to continue", new Label.LabelStyle(font, Color.BLACK)); label2.setFontScale(0.6f); table.add(label).width(getWidth()); table.row(); table.add(label2).width(getWidth()).expandY(); table.pad(0, 30, 0, 30); }
public SingleplayerSaveDeleteMenu(final Save save) { title = new Label(Localization.get("menu.singleplayer.delete.title"), skin.get("title", Label.LabelStyle.class)); text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin); delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin); back = MenuTools.getBackButton(this); text.setAlignment(Align.center); delete.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { ClientSaveManager.deleteSave(save); Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this); if (!(prev instanceof SingleplayerSavesMenu)) return; ((SingleplayerSavesMenu) prev).updateSavesList(); Adapter.setMenu(prev); } }); stage.addActor(title); stage.addActor(text); stage.addActor(delete); stage.addActor(back); }
public ActionDialog(Label text, Action action, I18NBundle bundle, Skin skin, Hexpert hexpert) { super(hexpert, skin); this.action = action; getBackground().setMinWidth(1000); getBackground().setMinHeight(400); text.setWrap(true); text.setAlignment(Align.center); getContentTable().add(text).width(getBackground().getMinWidth()).expandX(); getButtonTable().defaults().width(200).height(120).pad(15); TextButton textButtonYes = new TextButton(bundle.get("yes"), skin); getButtonTable().add(textButtonYes); setObject(textButtonYes, 1); TextButton textButtonNo = new TextButton(bundle.get("no"), skin); getButtonTable().add(textButtonNo); setObject(textButtonNo, null); }
public TileEffectDialog(Hexpert hexpert, Skin skin) { super(hexpert, skin, false); getContentTable().defaults().pad(15); for(int i = 0; i < TileType.values().length; i++) { TileType tileType = TileType.values()[i]; Image tileImage = new Image(new TextureRegion((Texture) hexpert.assetManager.get(SPRITE_FOLDER + tileType.name().toLowerCase() + "_tile.png"))); getContentTable().add(tileImage).width(96).height(96); Label lblDesc = new Label(hexpert.i18NBundle.get(tileType.name().toLowerCase() + "_effect"), skin); lblDesc.setAlignment(Align.center); getContentTable().add(lblDesc); getContentTable().row(); } }
public Band(final Klooni game, final GameLayout layout, final BaseScorer scorer) { this.scorer = scorer; bandTexture = Theme.getBlankTexture(); Label.LabelStyle labelStyle = new Label.LabelStyle(); labelStyle.font = game.skin.getFont("font"); scoreLabel = new Label("", labelStyle); scoreLabel.setAlignment(Align.center); infoLabel = new Label("pause menu", labelStyle); infoLabel.setAlignment(Align.center); scoreBounds = new Rectangle(); infoBounds = new Rectangle(); layout.update(this); }
ShareScoreScreen(final Klooni game, final Screen lastScreen, final int score, final boolean timeMode) { this.game = game; this.lastScreen = lastScreen; this.score = score; this.timeMode = timeMode; final Label.LabelStyle labelStyle = new Label.LabelStyle(); labelStyle.font = game.skin.getFont("font_small"); infoLabel = new Label("Generating image...", labelStyle); infoLabel.setColor(Klooni.theme.textColor); infoLabel.setAlignment(Align.center); infoLabel.layout(); infoLabel.setPosition( (Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f, (Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f); spriteBatch = new SpriteBatch(); }
public ContainerDialog(CharacterItemDataPacket[] itemsToShow, int gold, String title, ActorManipulator linkedContainer, PacketsSender packetsSender, long containerId, ItemPositionSupplier userInventoryTakeItemPositionSupplier) { super(title, linkedContainer, containerId); int numberOfItems = itemsToShow.length; addFieldRow(itemsToShow, packetsSender, numberOfItems, 0, userInventoryTakeItemPositionSupplier); for (int i = ROW_LENGTH; i < numberOfItems; i += ROW_LENGTH) { this.row(); addFieldRow(itemsToShow, packetsSender, numberOfItems, i, userInventoryTakeItemPositionSupplier); } this.row(); goldLabel = new StringValueLabel<>("Gold: ", Settings.DEFAULT_SKIN, gold); this.getButtonTable().add(goldLabel).align(Align.right); Button takeGoldButton = ButtonCreator.createTextButton("Take", () -> packetsSender.send(PacketsMaker.makeTakingGoldFromContainerPacket(containerId))); this.getButtonTable().add(takeGoldButton).align(Align.bottomRight); setWidth(ROW_LENGTH * BUTTON_SIZE + 50); setHeight(120); }
public ShopBuyingDialog(ShopItem item, UserInterface linkedInterface, PacketsSender packetsSender, long shopId) { super(DialogUtils.humanReadableFromItemIdentifier(item.getItem().getIdentifier()), linkedInterface.getDialogs(), item.getItem().getId()); this.item = item; totalPrice = new StringValueLabel<>("Total: ", getSkin(), item.getPrice()); Texture texture = item.getItem().getTexture(); Image image = new Image(texture); Table upperContainer = new Table(); upperContainer.add(image).width(32).height(32).padRight(43); upperContainer.add(numberOfItemsField).width(40).align(Align.right); this.getContentTable().add(upperContainer).align(Align.left); this.getContentTable().row(); this.getContentTable().add(totalPrice); this.getContentTable().row(); Button buyButton = ButtonCreator.createTextButton("Buy", () -> tryToBuyAction(packetsSender, shopId, linkedInterface)); this.getContentTable().add(buyButton); pack(); DialogUtils.centerPosition(this); }
/** * Zeigt den Namenswahl Bilschirm an * * @param camera die aktuelle Kamera * @param deltaTime die vergangene Zeit seit dem letztem Frame */ public void renderName(OrthographicCamera camera, float deltaTime) { strokeTimer += deltaTime; if (strokeTimer > 0.6f) { strokeTimer = 0f; stateSwitch = !stateSwitch; playerNameStroke = String.format("%s%s", playerName, stateSwitch ? " " : "|"); } fontLayout.setText(font, localeBundle.get("name_eingeben"), Color.WHITE, camera.viewportWidth, Align.center, false); font.draw(batch, fontLayout, -camera.viewportWidth / 2, camera.viewportHeight / 2 - 120); fontLayout.setText(font, playerNameStroke, Color.ROYAL, camera.viewportWidth, Align.center, false); font.draw(batch, fontLayout, -camera.viewportWidth / 2, 30); fontLayout.setText(smallFont, localeBundle.get("enter_bestaetigen"), Color.WHITE, camera.viewportWidth, Align.center, false); smallFont.draw(batch, fontLayout, -camera.viewportWidth / 2, -camera.viewportHeight / 2 + 70); }
public ServerSetupMenu(final Save save) { super(); title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class)); saveLabel = new Label(Localization.get("menu.server.save", save.name), skin); saveLabel.setAlignment(Align.center); port = new TextField("", skin); port.setMessageText(Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT))); port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); start = new TextButton(Localization.get("menu.server.start"), skin); back = MenuTools.getBackButton(this); start.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT) : Integer.parseInt(port.getText()); Adapter.setMenu(new ServerRunningMenu(save, p)); } }); stage.addActor(title); stage.addActor(saveLabel); stage.addActor(port); stage.addActor(start); stage.addActor(back); }
private void initLoseStage() { setViewport(new ScreenViewport(getCamera())); getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); getViewport().apply(true); Label youLoseLbl = new Label("You lost" , Assets._skin , "fontVeraBd24" ,"white"); playAgainBtn = new TextButton("Play Again", Assets._skin , "menu"); mainMenuBtn = new TextButton("Main Menu", Assets._skin , "menu"); Table container = new Table(Assets._skin); youLoseLbl.setColor(Color.RED); container.add(youLoseLbl).spaceBottom(100).row(); container.add(playAgainBtn).align(Align.left).spaceBottom(20).row(); container.add(mainMenuBtn).align(Align.left); container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); container.setFillParent(true); addActor(container); }
private void initWinStage() { setViewport(new ScreenViewport(getCamera())); getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); getViewport().apply(true); Label youWinLabel = new Label("You Won!" , Assets._skin , "fontVeraBd24" , "white"); playAgainBtn = new TextButton("Play Again", Assets._skin , "menu"); mainMenuBtn = new TextButton("Main Menu", Assets._skin , "menu"); Table container = new Table(Assets._skin); youWinLabel.setColor(Color.GREEN); container.add(youWinLabel).spaceBottom(100).row(); container.add(playAgainBtn).align(Align.left).spaceBottom(20).row(); container.add(mainMenuBtn).align(Align.left); container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); container.setFillParent(true); addActor(container); }
public LeftSection(Skin skin) { this.setSkin(skin); Table moneyStatPanel = new StatPanel(skin); Image coin = new Image(skin , "coin"); moneyLabel = new Label("",skin , "fontHemi20" , "white"); moneyStatPanel.add(coin).pad(5).align(Align.left).expand().size(23 , 21); moneyStatPanel.add(moneyLabel).align(Align.right).pad(5 , 5 , 5 ,10).expand(); this.add(moneyStatPanel).align(Align.right).size(120 , 30).spaceBottom(2).row(); Table grayPanel = new GrayPanel(skin); _laserTowerIcon = new Image(skin , "laser-tower-icon"); _plastmaTowerIcon = new Image(skin , "plastma-tower-icon"); _missleTurretIcon = new Image(skin,"missile-tower-icon"); _laserTowerTooltipTable = new LaserTowerTooltipTable(skin, TowerType.BASIC_LASER_TURRET); _plastmaTowerTooltipTable = new PlastmaTowerTooltipTable(skin, TowerType.PLASTMA_TOWER); _missileTowerTooltipTable = new MissileTowerTooltipTable(skin, TowerType.MISSILE_TURRET); _laserTowerIcon.addListener(_laserTowerTooltipTable.getTooltip()); _plastmaTowerIcon.addListener(_plastmaTowerTooltipTable.getTooltip()); _missleTurretIcon.addListener(_missileTowerTooltipTable.getTooltip()); grayPanel.add(_laserTowerIcon).size(32,32).pad(10).align(Align.topLeft); grayPanel.add(_plastmaTowerIcon).size(32,32).pad(10).align(Align.topLeft); grayPanel.add(_missleTurretIcon).size(32, 32).pad(10).align(Align.topLeft).expand(32,32); this.add(grayPanel).expand(); }
public PauseWindow(String title, Skin skin) { super(title, skin); this.setVisible(false); primaryMenu = new Table(skin); settingsPanel = new SettingsPanel(skin); _okButton = new TextButton("OK" , skin , "menu"); settingsPanel.add(_okButton); _resumeButton = new TextButton("Resume",Assets._skin , "menu"); _mainMenuButton = new TextButton("Main Menu",Assets._skin , "menu"); _settingsButton = new TextButton("Settings",Assets._skin , "menu"); primaryMenu.add(_resumeButton).padBottom(20f).row(); primaryMenu.add(_settingsButton).padBottom(20f).row(); primaryMenu.add(_mainMenuButton); this.add(primaryMenu).align(Align.center).fill(); }
public TextActor(String string,Color color,float targetwidth,TextAlign align,float scaleXY ,float x ,float y) { // TODO Auto-generated constructor stub font = book.base_font; text_string = string ; xpos = x; ypos = y; width = targetwidth ; text_color = (color==null?Color.BLACK:color) ; this.align = align; scale = scaleXY; font.getData().setScale(scaleXY); //font.setColor(Color.BLUE); best_score_text_layout = new GlyphLayout( font, text_string, text_color, width, this.align == TextAlign.align_cinter?Align.center:(this.align==TextAlign.align_right?Align.right:Align.left), true); }
public void init(MapProperties properties) { setOrigin(Align.center); this.properties = properties; bounds = new Rectangle(0, 0, getWidth(), getHeight()); ret_bounds = new Rectangle(bounds); if (getChildren().size > 0) for (int i = 0; i < getChildren().size; i++) { GameObject child = (GameObject) getChildren().get(i); child.setGameLayer(layer); init(properties); } for (int i = 0; i < controllers.size; i++) { controllers.get(i).init(this); } }
/** * Displays toast<br/> * Must be called at the end of {@link Game#render()}<br/> * @param delta {@link Graphics#getDeltaTime()} * @return activeness of the toast (true while being displayed, false otherwise) */ public boolean render(float delta) { timeToLive -= delta; if (timeToLive < 0) { return false; } renderer.begin(ShapeRenderer.ShapeType.Filled); renderer.circle(positionX, positionY + toastHeight / 2, toastHeight / 2); renderer.rect(positionX, positionY, toastWidth, toastHeight); renderer.circle(positionX + toastWidth, positionY + toastHeight / 2, toastHeight / 2); renderer.end(); spriteBatch.begin(); if (timeToLive > 0 && opacity > 0.15) { if (timeToLive < fadingDuration) { opacity = timeToLive / fadingDuration; } font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * opacity); font.draw(spriteBatch, msg, fontX, fontY, fontWidth, Align.center, true); } spriteBatch.end(); return true; }
public FloatingDialog(String title){ super(title, "dialog"); setFillParent(true); title().setAlignment(Align.center); getTitleTable().row(); getTitleTable().addImage("white", Colors.get("accent")) .growX().height(3f).pad(4f); }
@Override public void resize(float width, float height) { super.resize(width, height); logo.setSize(width, height / 6); MenuTools.center(logo); text.setSize(text.getPrefWidth(), text.getPrefHeight()); text.setPosition((width / 2) - (text.getWidth() / 2), 2); text.setAlignment(Align.center); }
@Override public void align(AlignEvent alignEvent) { if (selectedGroup.getAllActor().size > 1) { Actor tmp = selectedGroup.getAllActor().first(); Vector2 tmpVec = new Vector2(); tmp.localToStageCoordinates(tmpVec); for (Actor actor : selectedGroup.getAllActor()) { if (actor.equals(tmp)) continue; Vector2 vector2 = new Vector2(tmpVec); actor.getParent().stageToLocalCoordinates(vector2); switch (alignEvent.align) { case Align.left: actor.setPosition(vector2.x, actor.getY()); break; case Align.right: actor.setPosition(vector2.x + tmp.getWidth(), actor.getY() + actor.getHeight() / 2, Align.right); break; case Align.center: actor.setPosition(vector2.x + tmp.getWidth() / 2, actor.getY(Align.center), Align.center); break; case Config.centerH: actor.setPosition(actor.getX(Align.center), vector2.y + tmp.getHeight() / 2, Align.center); break; case Align.bottom: actor.setPosition(actor.getX(), vector2.y); break; case Align.top: actor.setPosition(actor.getX(), vector2.y + tmp.getHeight(), Align.topLeft); break; } } } }
/** * Zeigt den Bildschirm an, der dem Wizard-Schritt entspricht. * * @param camera die aktuelle Kamera * @param deltaTime die vergangene Zeit seit dem letztem Frame */ @Override public void render(OrthographicCamera camera, float deltaTime) { batch.setProjectionMatrix(camera.combined); batch.begin(); fontLayout.setText(smallFont, localeBundle.get("esc_abbrechen"), Color.LIGHT_GRAY, 50, Align.left, false); smallFont.draw(batch, fontLayout, -camera.viewportWidth / 2 + 5, camera.viewportHeight / 2 - 10); fontLayout.setText(font, localeBundle.get("erstellen"), Color.CORAL, camera.viewportWidth, Align.center, false); font.draw(batch, fontLayout, -camera.viewportWidth / 2, camera.viewportHeight / 2 - 50); switch (setupStep) { case STEP_1_NAME: renderName(camera, deltaTime); break; case STEP_2_GENDER: renderGender(camera); break; case STEP_3_TUTORIAL: renderTutorial(camera); break; case STEP_4_START: renderStart(camera); break; } batch.end(); }
private void init() { // Make the window around 3/4 of the screen setSize(width, height); // Position window in the middle setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2); // Center title getTitleLabel().setAlignment(Align.center); // Create the close button if (getTitleLabel().getText().length != 0) { closeButton = new TextButton("X", getSkin()); closeButton.setSize(20, 20); closeButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { closeButton.setChecked(false); close(); } }); getTitleTable().addActor(closeButton); closeButton.setPosition(getWidth() - closeButton.getWidth() - 5, 0); } getTitleTable().getCells().get(0).expandY().fillY(); setMovable(false); setModal(true); row(); }
public LockedTutDialog(Hexpert hexpert, Skin skin) { super(hexpert, skin, false); I18NBundle i18n = hexpert.i18NBundle; Label lblContent = new Label(i18n.get("lck_diag"), skin); lblContent.setAlignment(Align.center); lblContent.setWrap(true); getContentTable().defaults().pad(25); getContentTable().add(lblContent).width(800); }
private void initializePlayerNameLabels() { playerNameLabels = new ArrayList<>(sceneData.getGameData().getMaxNumPlayers()); for (int i = 0; i < sceneData.getGameData().getMaxNumPlayers(); i++) { LabelSceneObject label = new LabelSceneObject(sceneData.createLabel(Texts.WAITING_LABEL_TEXT, Assets.FONT_36PX_BLACK_NO_BORDER)); label.setBackgroundColor(Color.DARK_GRAY); label.setTextAlignment(Align.center); playerNameLabels.add(label); addSceneObject(label); } }
private float angleToNext(int index) { Tile current = path.get(index); Tile next = path.get(index + 1); float dX = current.getX(Align.center) - next.getX(Align.center); float dY = current.getY(Align.center) - next.getY(Align.center); return MathUtils.atan2(dY, dX) * MathUtils.radDeg; }
public Hud() { stage = new Stage(); background = Color.valueOf("#626262"); timer.setAlignment(Align.bottom, Align.center); stage.addActor(timer); }
NumberField(String text, Skin skin) { super(text, skin); setSize(115, 40); setPosition(Gdx.graphics.getWidth() / 3 - getWidth() / 2, Gdx.graphics.getHeight() / 2 + getHeight() / 4); setAlignment(Align.center); setTextFieldFilter(new TextFieldFilter.DigitsOnlyFilter()); }
public SplashMenu() { logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center); text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE)); stage.addActor(logo); stage.addActor(text); }
@Override protected void drawSprite(SpriteBatch batch, float x, float y) { BitmapFont font = GameCore.getFont(); font.setColor(shadow); font.draw(batch, text, x-1, y+1, 0, Align.center, false); font.setColor(main); font.draw(batch, text, x, y, 0, Align.center, false); }
@Override public void render(float delta) { if(rendered) { game.setScreen(new GameScreen()); dispose(); return; } Gdx.gl.glClearColor(0, 0, 0.2f, 1); // these are floats from 0 to 1. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); batch.setProjectionMatrix(camera.combined); // tells the batch to use the camera's coordinate system. batch.begin(); if(clicked) { font.draw(batch, "Loading...", camera.viewportWidth / 2, camera.viewportHeight / 2, 0, Align.center, false); rendered = true; } else { font.draw(batch, "Welcome to Miniventure! You're playing Version " + GameCore.VERSION, 100, 200); font.draw(batch, "Use the arrow keys or the mouse to move, the C key to attack, and the V key to", 100, 150); font.draw(batch, "interact with things and place items.", 100, 130); font.draw(batch, "Use the Q and E keys to cycle through your inventory.", 100, 80); font.draw(batch, "Click anywhere, or press space, to begin.", 100, 30); } batch.end(); if (Gdx.input.isTouched() || Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) clicked = true; }
public static void activate(Entity boss) { central = boss; final Transform cTransform = central.GetComponent(Transform.class); final BossHP bossHP = central.GetComponent(BossHP.class); spellName = Entity.Create(); spellName.AddComponent(new Transform(new Vector2(546, 700))); final TextRenderer nameRenderer = new TextRenderer(bossHP.spellNames[bossHP.current]); nameRenderer.labelAlign = Align.topRight; nameRenderer.lineAlign = Align.right; spellName.AddComponent(nameRenderer); spellName.AddComponent(new LambdaComponent(() -> { nameRenderer.setText(bossHP.spellNames[bossHP.current] == null ? "" : bossHP.spellNames[bossHP.current]); }, 0, 4)); lifeGauge = Entity.Create(); lifeGauge.AddComponent(new Transform(cTransform.position)); final CircularProgressRenderer circularProgressRenderer = new CircularProgressRenderer(); final ImageRenderer outerCircle = new ImageRenderer(ResourceManager.textures.get("bloodGaugeOuter"), -1); lifeGauge.AddComponent(outerCircle); lifeGauge.AddComponent(circularProgressRenderer); lifeGauge.AddComponent(new LambdaComponent(() -> { circularProgressRenderer.progress.toBack(); outerCircle.image.toBack(); circularProgressRenderer.progress.setPercent(bossHP.hp / (float) bossHP.maxhp); }, 1)); timeleft = Entity.Create(); timeleft.AddComponent(new Transform(new Vector2(285, 660))); final TextRenderer timeRenderer = new TextRenderer(bossHP.spellNames[bossHP.current]); timeRenderer.labelAlign = Align.center; timeRenderer.lineAlign = Align.center; timeleft.AddComponent(timeRenderer); timeleft.AddComponent(new LambdaComponent(() -> { timeRenderer.setText(String.format("%.2f", (bossHP.time[bossHP.current] - bossHP.timer) / 60f)); }, 1)); mIsActive = true; }
@Override public void layout(float x, float y, float width, float height) { buttonsTable.pack(); buttonsTable.invalidate(); buttonsTable.validate(); buttonsTable.layout(); titleLabel.setFontScale(getTitleScale()); titleLabel.setSize(width, height/8); titleLabel.setPosition(width / 2f, 2 * height / 3, Align.center); }