use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class AnimationTest method render.
@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
for (int i = 0; i < cavemen.length; i++) {
Caveman caveman = cavemen[i];
TextureRegion frame = caveman.headsLeft ? leftWalk.getKeyFrame(caveman.stateTime, true) : rightWalk.getKeyFrame(caveman.stateTime, true);
batch.draw(frame, caveman.pos.x, caveman.pos.y);
}
batch.end();
for (int i = 0; i < cavemen.length; i++) {
cavemen[i].update(Gdx.graphics.getDeltaTime());
}
fpsLog.log();
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion 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();
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class ParallaxTest method create.
@Override
public void create() {
Texture texture = new Texture(Gdx.files.internal("data/layers.png"));
layers = new TextureRegion[3];
layers[0] = new TextureRegion(texture, 0, 0, 542, 363);
layers[1] = new TextureRegion(texture, 0, 363, 1024, 149);
layers[2] = new TextureRegion(texture, 547, 0, 224, 51);
camera = new ParallaxCamera(480, 320);
controller = new OrthoCamController(camera);
Gdx.input.setInputProcessor(controller);
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion 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.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class NinePatchTest method newPatchPix.
// Make a new 'pixmapSize' square texture region with 'patchSize' patches in it. Each patch is a different color.
static TextureRegion newPatchPix(int patchSize, int pixmapSize) {
final int pixmapDim = MathUtils.nextPowerOfTwo(pixmapSize);
Pixmap p = new Pixmap(pixmapDim, pixmapDim, Pixmap.Format.RGBA8888);
p.setColor(1, 1, 1, 0);
p.fill();
for (int x = 0; x < pixmapSize; x += patchSize) {
for (int y = 0; y < pixmapSize; y += patchSize) {
p.setColor(x / (float) pixmapSize, y / (float) pixmapSize, 1.0f, 1.0f);
p.fillRectangle(x, y, patchSize, patchSize);
}
}
return new TextureRegion(new Texture(p), pixmapSize, pixmapSize);
}
Aggregations