Search in sources :

Example 11 with Image

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

the class StagePerformanceTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    font = new BitmapFont();
    stage = new Stage(new ScalingViewport(Scaling.fit, 24, 12));
    regions = new TextureRegion[8 * 8];
    sprites = new Sprite[24 * 12];
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    for (int y = 0; y < 8; y++) {
        for (int x = 0; x < 8; x++) {
            regions[x + y * 8] = new TextureRegion(texture, x * 32, y * 32, 32, 32);
        }
    }
    Random rand = new Random();
    for (int y = 0, i = 0; y < 12; y++) {
        for (int x = 0; x < 24; x++) {
            Image img = new Image(regions[rand.nextInt(8 * 8)]);
            img.setBounds(x, y, 1, 1);
            stage.addActor(img);
            sprites[i] = new Sprite(regions[rand.nextInt(8 * 8)]);
            sprites[i].setPosition(x, y);
            sprites[i].setSize(1, 1);
            i++;
        }
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Random(java.util.Random) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Stage(com.badlogic.gdx.scenes.scene2d.Stage) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ScalingViewport(com.badlogic.gdx.utils.viewport.ScalingViewport)

Example 12 with Image

use of com.badlogic.gdx.scenes.scene2d.ui.Image 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 13 with Image

use of com.badlogic.gdx.scenes.scene2d.ui.Image 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 14 with Image

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

the class GroupFadeTest method create.

@Override
public void create() {
    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    stage = new Stage();
    for (int i = 0; i < 100; i++) {
        Image img = new Image(new TextureRegion(texture));
        img.setX((float) Math.random() * 480);
        img.setY((float) Math.random() * 320);
        img.getColor().a = (float) Math.random() * 0.5f + 0.5f;
        stage.addActor(img);
    }
    stage.getRoot().addAction(forever(sequence(fadeOut(3), fadeIn(3))));
}
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 15 with Image

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

the class ComplexActionTest method create.

@Override
public void create() {
    stage = new Stage();
    Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)), parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    final Image img1 = new Image(new TextureRegion(texture));
    img1.setSize(100, 100);
    img1.setOrigin(50, 50);
    img1.setPosition(50, 50);
    final Image img2 = new Image(new TextureRegion(texture));
    img2.setSize(50, 50);
    img2.setOrigin(50, 50);
    img2.setPosition(150, 150);
    stage.addActor(img1);
    stage.addActor(img2);
    img1.addAction(complexAction);
// img2.action(complexAction.copy());
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Action(com.badlogic.gdx.scenes.scene2d.Action) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

Image (com.badlogic.gdx.scenes.scene2d.ui.Image)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)16 Texture (com.badlogic.gdx.graphics.Texture)15 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)9 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)7 Actor (com.badlogic.gdx.scenes.scene2d.Actor)6 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)6 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)5 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)5 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)4 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)3 Pixmap (com.badlogic.gdx.graphics.Pixmap)2 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)2 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)2 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)2 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)2