Search in sources :

Example 61 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.

the class ActionSequenceTest method create.

@Override
public void create() {
    stage = new Stage();
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    img = new Image(new TextureRegion(texture));
    img.setSize(100, 100);
    img.setOrigin(50, 50);
    img.setPosition(100, 100);
    img2 = new Image(new TextureRegion(texture));
    img2.setSize(100, 100);
    img2.setOrigin(50, 50);
    img2.setPosition(100, 100);
    img3 = new Image(new TextureRegion(texture));
    img3.setSize(100, 100);
    img3.setOrigin(50, 50);
    img3.setPosition(100, 100);
    stage.addActor(img);
    stage.addActor(img2);
    stage.addActor(img3);
    img.addAction(sequence());
    img2.addAction(parallel(sequence(), moveBy(100, 0, 1)));
    img3.addAction(sequence(parallel(moveBy(100, 200, 2)), Actions.run(this)));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture)

Example 62 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.

the class BitmapFontTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    // font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
    font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
    // font = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")).generateFont(new FreeTypeFontParameter());
    font.getData().markupEnabled = true;
    font.getData().breakChars = new char[] { '-' };
    multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt"));
    // Add user defined color
    Colors.put("PERU", Color.valueOf("CD853F"));
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
    stage = new Stage(new ScreenViewport());
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    BitmapFont labelFont = skin.get("default-font", BitmapFont.class);
    labelFont.getData().markupEnabled = true;
    // Notice that the last [] has been deliberately added to test the effect of excessive pop operations.
    // They are silently ignored, as expected.
    label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>", skin);
    label.setPosition(100, 200);
    stage.addActor(label);
    Window window = new Window("[RED]Multicolor[GREEN] Title", skin);
    window.setPosition(400, 300);
    window.pack();
    stage.addActor(window);
    layout = new GlyphLayout();
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) GlyphLayout(com.badlogic.gdx.graphics.g2d.GlyphLayout) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 63 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.

the class ActionTest method create.

@Override
public void create() {
    stage = new Stage();
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    final Image img = new Image(new TextureRegion(texture));
    img.setSize(100, 100);
    img.setOrigin(50, 50);
    img.setPosition(100, 100);
    // img.addAction(forever(sequence(delay(1.0f), new Action() {
    // public boolean act (float delta) {
    // System.out.println(1);
    // img.clearActions();
    // return true;
    // }
    // })));
    img.addAction(Actions.moveBy(100, 0, 2));
    img.addAction(Actions.after(Actions.scaleTo(2, 2, 2)));
    stage.addActor(img);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture)

Example 64 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.

the class NoncontinuousRenderingTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    texture = new Texture("data/badlogic.jpg");
    region = new TextureRegion(texture);
    stage = new Stage(new ScreenViewport(), batch);
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.add("default", font = new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
    populateTable();
    Gdx.graphics.setContinuousRendering(false);
    Gdx.graphics.requestRendering();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 65 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.

the class ParticleEmittersTest method setupUI.

private void setupUI() {
    ui = new Stage(new ExtendViewport(640, 480));
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skipCleanup = new CheckBox("Skip blend function clean-up", skin);
    skipCleanup.setTransform(false);
    skipCleanup.addListener(listener);
    logLabel = new Label("", skin.get(LabelStyle.class));
    clearEmitters = new TextButton("Clear screen", skin);
    clearEmitters.setTransform(false);
    clearEmitters.addListener(listener);
    Table table = new Table();
    table.setTransform(false);
    table.setFillParent(true);
    table.defaults().padTop(5).left();
    table.top().left().padLeft(5);
    table.add(skipCleanup).row();
    table.add(clearEmitters).row();
    table.add(logLabel);
    ui.addActor(table);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ExtendViewport(com.badlogic.gdx.utils.viewport.ExtendViewport) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Aggregations

Stage (com.badlogic.gdx.scenes.scene2d.Stage)107 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)46 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)46 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)38 Texture (com.badlogic.gdx.graphics.Texture)36 Actor (com.badlogic.gdx.scenes.scene2d.Actor)32 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)30 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)30 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)28 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)22 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)22 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)20 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)19 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)15 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)13 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)12 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)11 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)10 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)10