use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class BitmapFontAlignmentTest method create.
@Override
public void create() {
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
renderMode = (renderMode + 1) % 6;
return false;
}
});
spriteBatch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
logoSprite = new Sprite(texture);
logoSprite.setColor(1, 1, 1, 0.6f);
logoSprite.setBounds(50, 100, 400, 100);
font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle("data/verdana39.png", FileType.Internal), false);
cache = font.newFontCache();
layout = new GlyphLayout();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class BitmapFontFlipTest method create.
@Override
public void create() {
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
renderMode = (renderMode + 1) % 4;
return false;
}
});
spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
logoSprite = new Sprite(texture);
logoSprite.flip(false, true);
logoSprite.setPosition(0, 320 - 256);
logoSprite.setColor(1, 1, 1, 0.5f);
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true);
cache1 = font.newFontCache();
cache2 = font.newFontCache();
cache3 = font.newFontCache();
cache4 = font.newFontCache();
cache5 = font.newFontCache();
createCaches("cached", cache1, cache2, cache3, cache4, cache5);
font.getData().setScale(1.33f);
cacheScaled1 = font.newFontCache();
cacheScaled2 = font.newFontCache();
cacheScaled3 = font.newFontCache();
cacheScaled4 = font.newFontCache();
cacheScaled5 = font.newFontCache();
createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class BitmapFontMetricsTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
atlas = new TextureAtlas("data/pack");
smallFont = new BitmapFont();
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), atlas.findRegion("verdana39"), false);
font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class Gdx2DTest method create.
@Override
public void create() {
batch = new SpriteBatch();
sprites = new ArrayList<Sprite>();
Gdx2DPixmap[] pixmaps = testPixmaps();
Gdx2DPixmap composite = new Gdx2DPixmap(512, 256, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);
composite.clear(0);
composite.setBlend(Gdx2DPixmap.GDX2D_BLEND_NONE);
for (int i = 0; i < pixmaps.length; i++) {
composite.setScale(Gdx2DPixmap.GDX2D_SCALE_NEAREST);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 0, 64, 64);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 64, 16, 16);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 0, 64, 64);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 64, 16, 16);
composite.setScale(Gdx2DPixmap.GDX2D_SCALE_LINEAR);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 100, 64, 64);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 164, 16, 16);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 100, 64, 64);
composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 164, 16, 16);
Sprite sprite = new Sprite(textureFromPixmap(pixmaps[i]));
sprite.setPosition(10 + i * 32, 10);
sprites.add(sprite);
}
Sprite sprite = new Sprite(textureFromPixmap(composite));
sprite.setPosition(10, 50);
sprites.add(sprite);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class AnimationTest method create.
@Override
public void create() {
texture = new Texture(Gdx.files.internal("data/walkanim.png"));
TextureRegion[] leftWalkFrames = TextureRegion.split(texture, 64, 64)[0];
TextureRegion[] rightWalkFrames = new TextureRegion[leftWalkFrames.length];
for (int i = 0; i < rightWalkFrames.length; i++) {
TextureRegion frame = new TextureRegion(leftWalkFrames[i]);
frame.flip(true, false);
rightWalkFrames[i] = frame;
}
leftWalk = new Animation<TextureRegion>(0.25f, leftWalkFrames);
rightWalk = new Animation<TextureRegion>(0.25f, rightWalkFrames);
cavemen = new Caveman[100];
for (int i = 0; i < 100; i++) {
cavemen[i] = new Caveman((float) Math.random() * Gdx.graphics.getWidth(), (float) Math.random() * Gdx.graphics.getHeight(), Math.random() > 0.5 ? true : false);
}
batch = new SpriteBatch();
fpsLog = new FPSLogger();
}
Aggregations