Search in sources :

Example 1 with Node

use of com.badlogic.gdx.scenes.scene2d.ui.Tree.Node in project libgdx by libgdx.

the class TreeTest method create.

public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Table table = new Table();
    table.setFillParent(true);
    stage.addActor(table);
    final Tree tree = new Tree(skin);
    final Node moo1 = new Node(new TextButton("moo1", skin));
    final Node moo2 = new Node(new TextButton("moo2", skin));
    final Node moo3 = new Node(new TextButton("moo3", skin));
    final Node moo4 = new Node(new TextButton("moo4", skin));
    final Node moo5 = new Node(new TextButton("moo5", skin));
    tree.add(moo1);
    tree.add(moo2);
    moo2.add(moo3);
    moo3.add(moo4);
    tree.add(moo5);
    moo5.getActor().addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            tree.remove(moo4);
        }
    });
    table.add(tree).fill().expand();
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Node(com.badlogic.gdx.scenes.scene2d.ui.Tree.Node) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Tree(com.badlogic.gdx.scenes.scene2d.ui.Tree) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 Tree (com.badlogic.gdx.scenes.scene2d.ui.Tree)1 Node (com.badlogic.gdx.scenes.scene2d.ui.Tree.Node)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1