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++;
}
}
}
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)));
}
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);
}
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))));
}
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());
}
Aggregations