Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Stack#add()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Stack#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectBoxWidget.java From talos with Apache License 2.0 | 6 votes |
@Override public Actor getSubWidget() { selectBox = new SelectBox<>(TalosMain.Instance().UIStage().getSkin(), "propertyValue"); noValueLabel = new Label("", TalosMain.Instance().UIStage().getSkin()); noValueLabel.setAlignment(Align.right); stack = new Stack(); stack.add(noValueLabel); stack.add(selectBox); noValueLabel.setVisible(false); listener = new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { String newValue = selectBox.getSelected(); valueChanged(newValue); } }; selectBox.addListener(listener); return stack; }
Example 2
Source File: MessageTestBase.java From gdx-ai with Apache License 2.0 | 6 votes |
public void create () { lastUpdateTime = 0; testStack = new Stack(); container.stage.getRoot().addActorAt(0, testStack); testStack.setSize(container.stageWidth, container.stageHeight); testStack.add(testTable = new Table() { @Override public void act (float delta) { float time = GdxAI.getTimepiece().getTime(); if (lastUpdateTime != time) { lastUpdateTime = time; super.act(GdxAI.getTimepiece().getDeltaTime()); } } }); testStack.layout(); }
Example 3
Source File: Scene2dSteeringTest.java From gdx-ai with Apache License 2.0 | 6 votes |
@Override public void create () { lastUpdateTime = 0; testStack = new Stack(); container.stage.getRoot().addActorAt(0, testStack); testStack.setSize(container.stageWidth, container.stageHeight); testStack.add(testTable = new Table() { @Override public void act (float delta) { float time = GdxAI.getTimepiece().getTime(); if (lastUpdateTime != time) { lastUpdateTime = time; super.act(GdxAI.getTimepiece().getDeltaTime()); } } }); testStack.layout(); }
Example 4
Source File: CreatureQueueWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override protected void initialize() { creaturesList.defaults().pad(2); creaturesList.padTop(12); Image left = new Image(Config.skin, "ui-creature-queue-gradient-left"); left.setScaling(Scaling.stretchY); left.setAlign(Align.left); left.setTouchable(Touchable.disabled); Image right = new Image(Config.skin, "ui-creature-queue-gradient-right"); right.setScaling(Scaling.stretchY); right.setAlign(Align.right); right.setTouchable(Touchable.disabled); Stack stack = new Stack(); stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle())); stack.add(left); stack.add(right); Table content = new Table(Config.skin); content.setTouchable(Touchable.enabled); content.setBackground("ui-inventory-ability-window-background"); content.defaults().pad(2); content.add(new LocLabel("ui-turns-order")).row(); content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row(); content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row(); table.add(content); }
Example 5
Source File: BehaviorTreeTests.java From gdx-ai with Apache License 2.0 | 5 votes |
private void changeTest (int testIndex) { // Dispose the previous test (if any) if (currentTest != null) currentTest.dispose(); // Add the new test currentTest = tests[testIndex]; Gdx.app.log("BehaviorTreeTests", "***********************************************"); Gdx.app.log("BehaviorTreeTests", "Starting test " + currentTest.getName()); Gdx.app.log("BehaviorTreeTests", "***********************************************"); String description = currentTest.getDescription(); if (description != null) { Gdx.app.log("BehaviorTreeTests", description); Gdx.app.log("BehaviorTreeTests", "***********************************************"); testDescriptionLabel.setText(description); } else { testDescriptionLabel.setText("Run the tree, look at the log and see what happens"); } Stack testStack = new Stack() { @Override public void act (float delta) { boolean paused = pauseButton.isChecked(); getChildren().peek().setVisible(paused); if (!paused) { // Update AI time GdxAI.getTimepiece().update(delta); // Call super super.act(delta); } } }; testStack.add(currentTest.createActor(skin)); testStack.add(new Image(skin, "translucent")); splitPane.setSecondWidget(testStack); }
Example 6
Source File: PathFinderTests.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public void create () { Gdx.gl.glClearColor(.3f, .3f, .3f, 1); skin = new Skin(Gdx.files.internal("data/uiskin.json")); // Enable color markup BitmapFont font = skin.get("default-font", BitmapFont.class); font.getData().markupEnabled = true; stage = new Stage(); stage.setDebugAll(DEBUG_STAGE); stageWidth = stage.getWidth(); stageHeight = stage.getHeight(); Gdx.input.setInputProcessor(new InputMultiplexer(stage)); Stack stack = new Stack(); stage.addActor(stack); stack.setSize(stageWidth, stageHeight); testsTable = new Table(); stack.add(testsTable); // Create behavior selection window List<String> testList = createTestList(); algorithmSelectionWindow = addBehaviorSelectionWindow("Path Finder Tests", testList, 0, -1); // Set selected test changeTest(0); stage.addActor(new FpsLabel("FPS: ", skin)); }
Example 7
Source File: ParallelVsSequenceTest.java From gdx-ai with Apache License 2.0 | 4 votes |
public TestScreen (final ParallelVsSequenceTest test, Skin skin) { this.test = test; this.skin = skin; lastUpdateTime = 0; gameOver = false; greenFishTextureRegion = new TextureRegion(new Texture("data/green_fish.png")); badlogicTextureRegion = new TextureRegion(new Texture("data/badlogicsmall.jpg")); targetTextureRegion = new TextureRegion(new Texture("data/target.png")); shapeRenderer = new ShapeRenderer(); stage = new Stage(); Stack testStack = new Stack(); stage.addActor(testStack); // Add translucent panel (it's only visible when AI is paused) final Image translucentPanel = new Image(skin, "translucent"); translucentPanel.setSize(stage.getWidth(), stage.getHeight()); translucentPanel.setVisible(false); stage.addActor(translucentPanel); // Create status bar Table statusBar = new Table(skin); statusBar.left().bottom(); statusBar.row().height(26); statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left(); statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15); statusBar.add(new IntValueLabel("Sequence (Fish): ", 0, skin) { @Override public int getValue () { return sequencePredator.score; } }).padLeft(15); statusBar.add(new IntValueLabel("Parallel (Badlogics): ", 0, skin) { @Override public int getValue () { return parallelPredator.score; } }).padLeft(15); stage.addActor(statusBar); // Add test table testStack.setSize(stage.getWidth(), stage.getHeight()); testStack.add(testTable = new Table() { @Override public void act (float delta) { float time = GdxAI.getTimepiece().getTime(); if (lastUpdateTime != time) { lastUpdateTime = time; super.act(GdxAI.getTimepiece().getDeltaTime()); } } }); testStack.layout(); this.sheeps = new Array<Sheep>(); for (int i = 0; i < 30; i++) { Sheep sheep = new Sheep(targetTextureRegion); sheep.setMaxLinearAcceleration(50); sheep.setMaxLinearSpeed(80); sheep.setMaxAngularAcceleration(10); // greater than 0 because independent facing is enabled sheep.setMaxAngularSpeed(5); Wander<Vector2> wanderSB = new Wander<Vector2>(sheep) // .setFaceEnabled(true) // We want to use Face internally (independent facing is on) .setAlignTolerance(0.001f) // Used by Face .setDecelerationRadius(5) // Used by Face .setTimeToTarget(0.1f) // Used by Face .setWanderOffset(90) // .setWanderOrientation(10) // .setWanderRadius(40) // .setWanderRate(MathUtils.PI2 * 4); sheep.setSteeringBehavior(wanderSB); setRandomNonOverlappingPosition(sheep, sheeps, 5); setRandomOrientation(sheep); testTable.addActor(sheep); sheeps.add(sheep); } sequencePredator = createPredator(false); parallelPredator = createPredator(true); // Create GameOver panel gameOverButton = new TextButton("Game Over", skin); gameOverButton.setVisible(false); gameOverButton.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { test.backToPreviousScreen(); } }); testTable.add(gameOverButton); }
Example 8
Source File: ResumeVsJoinTest.java From gdx-ai with Apache License 2.0 | 4 votes |
public TestScreen (final ResumeVsJoinTest test, Skin skin) { this.test = test; this.skin = skin; lastUpdateTime = 0; gameOver = false; greenFishTextureRegion = new TextureRegion(new Texture("data/green_fish.png")); badlogicTextureRegion = new TextureRegion(new Texture("data/badlogicsmall.jpg")); targetTextureRegion = new TextureRegion(new Texture("data/target.png")); shapeRenderer = new ShapeRenderer(); stage = new Stage(); Stack testStack = new Stack(); stage.addActor(testStack); // Add translucent panel (it's only visible when AI is paused) final Image translucentPanel = new Image(skin, "translucent"); translucentPanel.setSize(stage.getWidth(), stage.getHeight()); translucentPanel.setVisible(false); stage.addActor(translucentPanel); // Create status bar Table statusBar = new Table(skin); statusBar.left().bottom(); statusBar.row().height(26); statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left(); statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15); statusBar.add(new IntValueLabel("Resume (Fish): ", 0, skin) { @Override public int getValue () { return resumePredator.score; } }).padLeft(15); statusBar.add(new IntValueLabel("Join (Badlogics): ", 0, skin) { @Override public int getValue () { return joinPredator.score; } }).padLeft(15); stage.addActor(statusBar); // Add test table testStack.setSize(stage.getWidth(), stage.getHeight()); testStack.add(testTable = new Table() { @Override public void act (float delta) { float time = GdxAI.getTimepiece().getTime(); if (lastUpdateTime != time) { lastUpdateTime = time; super.act(GdxAI.getTimepiece().getDeltaTime()); } } }); testStack.layout(); this.sheeps = new Array<Sheep>(); for (int i = 0; i < 30; i++) { Sheep sheep = new Sheep(targetTextureRegion); sheep.setMaxLinearAcceleration(50); sheep.setMaxLinearSpeed(80); sheep.setMaxAngularAcceleration(10); // greater than 0 because independent facing is enabled sheep.setMaxAngularSpeed(5); Wander<Vector2> wanderSB = new Wander<Vector2>(sheep) // .setFaceEnabled(true) // We want to use Face internally (independent facing is on) .setAlignTolerance(0.001f) // Used by Face .setDecelerationRadius(5) // Used by Face .setTimeToTarget(0.1f) // Used by Face .setWanderOffset(90) // .setWanderOrientation(10) // .setWanderRadius(40) // .setWanderRate(MathUtils.PI2 * 4); sheep.setSteeringBehavior(wanderSB); setRandomNonOverlappingPosition(sheep, sheeps, 5); setRandomOrientation(sheep); testTable.addActor(sheep); sheeps.add(sheep); } resumePredator = createPredator(false); joinPredator = createPredator(true); // Create GameOver panel gameOverButton = new TextButton("Game Over", skin); gameOverButton.setVisible(false); gameOverButton.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { test.backToPreviousScreen(); } }); testTable.add(gameOverButton); }
Example 9
Source File: TextureDropWidget.java From talos with Apache License 2.0 | 3 votes |
public void init(TextureRegion region, Skin skin, float width) { Stack stack = new Stack(); image = new Image(region); Image border = new Image(skin.getDrawable("border")); stack.add(image); stack.add(border); add(stack).size(width); }