List of usage examples for com.badlogic.gdx.scenes.scene2d Stage addActor
public void addActor(Actor actor)
From source file:at.highstreeto.xnllayoutparser.LayoutParser.java
License:Apache License
/** * Convenient method that adds the actors loaded from given XML file to the given Stage * @param layoutFile Contains the layout of the scene * @param stage Stage, to which the actors should be added * @param skin Skin for the actors //from www. j a va2 s . c om * @throws LayoutParseException */ public void load(FileHandle layoutFile, Stage stage, Skin skin) throws LayoutParseException { for (Actor i : load(layoutFile, skin)) { stage.addActor(i); } }
From source file:com.advancedtelematic.toyapp.AboutScreen.java
@Override public void resize(int width, int height) { super.resize(width, height); //To change body of overridden methods use File | Settings | File Templates. Stage stage = getStage(); Skin skin = getSkin();/* www . j a v a 2s. com*/ Label licenseLabel = new Label(Gdx.files.internal("freebsd_license.txt").readString("UTF-8"), skin); ScrollPane pane = new ScrollPane(licenseLabel); pane.setFillParent(true); stage.addActor(pane); }
From source file:com.agateau.pixelwheels.racescreen.Hud.java
License:Open Source License
public Hud(Assets assets, Stage stage) { mRoot = new AnchorGroup(); BUTTON_SIZE_PX = assets.findRegion("hud-right").getRegionWidth(); stage.addActor(mRoot); }
From source file:com.aia.hichef.ui.n.MyDialog.java
License:Apache License
/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */ public MyDialog show(Stage stage) { clearActions();/*from www . ja va 2s.c o m*/ removeCaptureListener(ignoreTouchDown); previousKeyboardFocus = null; Actor actor = stage.getKeyboardFocus(); if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor; previousScrollFocus = null; actor = stage.getScrollFocus(); if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor; pack(); setPosition(Math.round((stage.getWidth() - getWidth()) / 2), Math.round((stage.getHeight() - getHeight()) / 2)); stage.addActor(this); stage.setKeyboardFocus(this); stage.setScrollFocus(this); if (fadeDuration > 0) { getColor().a = 0; addAction(Actions.fadeIn(fadeDuration, Interpolation.fade)); } return this; }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createLevelAndHealthLayer() { Stage stage = new Stage(new StretchViewport(486, 864)); Skin skin = new Skin(); Table table = new Table(); table.top().pad(10);//from ww w .j ava2s . c o m FreeTypeFontGenerator generator = new FreeTypeFontGenerator( Gdx.files.internal("ui/fonts/Century Gothic Bold.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 40; parameter.borderColor = Color.BLACK; parameter.borderWidth = 3; BitmapFont font = generator.generateFont(parameter); generator.dispose(); Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE); skin.add("star", new Texture("ui/icons/star.png")); skin.add("shield", new Texture("ui/icons/shield.png")); skin.add("brick", new Texture("ui/icons/brick.png")); skin.add("swipe128", new Texture("ui/icons/swipe128.png")); float padding = 10; Image icon = new Image(skin.getDrawable("star")); if (Global.debugLevelUp) { icon.addListener(new ClickListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (Engine.systemManager.has(LevelProgressionSystem.class)) { for (Entity entity : Engine.systemManager.get(LevelProgressionSystem.class).entities) { Engine.garbageManager.markForDeletion(entity); } } super.touchUp(event, x, y, pointer, button); } }); } table.add(icon).pad(padding); Label levelLabel = new Label("", labelStyle); table.add(levelLabel).pad(padding); icon = new Image(skin.getDrawable("shield")); table.add(icon).pad(padding); Label healthLabel = new Label("", labelStyle); table.add(healthLabel).pad(padding); icon = new Image(skin.getDrawable("brick")); table.add(icon).pad(padding); Label brickLabel = new Label("", labelStyle); table.add(brickLabel).pad(padding); table.row(); // swipe if (Engine.systemManager.has(LevelProgressionSystem.class)) { if (Engine.systemManager.get(LevelProgressionSystem.class).level < 5) { icon = new Image(skin.getDrawable("swipe128")); table.add(icon).padTop(350).colspan(6); Global.swipeIcon = icon; } } // table.setDebug(true); table.setFillParent(true); stage.addActor(table); Global.LEVEL_LABEL = levelLabel; Global.HEALTH_LABEL = healthLabel; Global.BRICK_LABEL = brickLabel; if (Engine.systemManager.has(LevelProgressionSystem.class)) { Global.LEVEL_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).level); Global.HEALTH_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).health); Global.BRICK_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).nrOfBricks); } Engine.inputManager.add(stage); return new Layer("topLayer", stage, table); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createScoreLayer() { Stage stage = new Stage(); Table table = new Table(); BitmapFont font = new BitmapFont(); font.scale(2);//from ww w. ja v a2 s. c o m Button button; Skin skin = new Skin(); skin.add("bluebox", new Texture("textures/bluebox.jpg")); skin.add("greenbox", new Texture("textures/greenbox.jpg")); skin.add("redbox", new Texture("textures/redbox2.jpg")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("redbox"), skin.getDrawable("greenbox"), skin.getDrawable("bluebox"), font); button = new ImageTextButton("0", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); table.add(button).pad(5).center(); table.pack(); table.setPosition(Gdx.graphics.getWidth() / 2 - table.getWidth() / 2, Gdx.graphics.getHeight() - table.getHeight()); stage.addActor(table); Global.scoreButton = button; return new Layer("scoreLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createFireLayer() { Stage stage = new Stage(new StretchViewport(640, 480)); Table table = new Table(); BitmapFont font = new BitmapFont(); Button button;/*from ww w. ja v a 2s .co m*/ Skin skin = new Skin(); skin.add("bluebox", new Texture("textures/bluebox.jpg")); skin.add("greenbox", new Texture("textures/greenbox.jpg")); skin.add("redbox", new Texture("textures/redbox.jpg")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("redbox"), skin.getDrawable("greenbox"), skin.getDrawable("bluebox"), font); button = new ImageTextButton("Fire", style); button.setHeight(50); button.setWidth(50); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Gdx.input.getInputProcessor().keyDown(Keys.SPACE); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { Gdx.input.getInputProcessor().keyUp(Keys.SPACE); } }); table.add(button).pad(50).center(); table.pack(); table.setPosition(640 - table.getWidth(), 0); stage.addActor(table); Engine.inputManager.add(stage); return new Layer("fireLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createJoystickLayer() { Stage stage = new Stage(new StretchViewport(1280, 720)); Table table = new Table(); MyListener listener = new MyListener(); BitmapFont font = new BitmapFont(); Button button;//from w ww.j av a 2 s. c o m Skin skin = new Skin(); skin.add("cirlce", new Texture("textures/circle.png")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), font); button = new ImageTextButton("Move", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new MoveListener()); table.add(button).pad(50).expandX().left(); button = new ImageTextButton("Fire", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(listener); table.add(button).pad(50).bottom().right(); table.setDebug(true); table.setFillParent(true); table.bottom().left(); stage.addActor(table); Engine.inputManager.add(stage); return new Layer("joystickLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createJoystickControlLayer() { Stage stage = new Stage(new StretchViewport(1280, 720)); Table table = new Table(); BitmapFont font = new BitmapFont(); Button button;/*from w ww . j a v a 2 s. com*/ Skin skin = new Skin(); skin.add("cirlce", new Texture("textures/circle.png")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), font); button = new ImageTextButton("Debug Options", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Engine.game.setScreen(Engine.screens.get("debug")); return false; } }); table.add(button).pad(50).padLeft(100).expandX().left(); table.row(); button = new ImageTextButton("L Boost", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(true, false, true)); table.add(button).pad(50).padLeft(100).expandX().left(); button = new ImageTextButton("R Boost", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(false, true, true)); table.add(button).pad(50).padRight(100).bottom().right(); table.row(); button = new ImageTextButton("Left", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(true, false, false)); table.add(button).pad(50).padLeft(100).expandX().left(); button = new ImageTextButton("Right", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(false, true, false)); table.add(button).pad(50).padRight(100).bottom().right(); // table.setDebug(true); table.setFillParent(true); table.bottom().left(); stage.addActor(table); if (Engine.systemManager.has(OrbitCameraSystem.class) && Engine.systemManager.get(OrbitCameraSystem.class).mouseListener) { InputProcessor tmp = Engine.systemManager.get(OrbitCameraSystem.class).orbitCameraController; Engine.inputManager.remove(tmp); Engine.inputManager.add(stage); Engine.inputManager.add(tmp); } else { Engine.inputManager.add(stage); } return new Layer("controlLayer", stage); }
From source file:com.bladecoder.engineeditor.utils.Message.java
License:Apache License
private static void add(Stage stage, String text) { msg.clearActions();/*from ww w . j av a 2 s . c o m*/ msg.setText(text); GlyphLayout textLayout = new GlyphLayout(); textLayout.setText(msg.getStyle().font, text, Color.BLACK, stage.getWidth() * .8f, Align.center, true); msg.setSize(textLayout.width + textLayout.height, textLayout.height + textLayout.height * 2); if (!stage.getActors().contains(msg, true)) stage.addActor(msg); msg.setPosition(Math.round((stage.getWidth() - msg.getWidth()) / 2), Math.round((stage.getHeight() - msg.getHeight()) / 2)); msg.invalidate(); }