use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TiledMapLayerOffsetTest method create.
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, (w / h) * 10, 10);
camera.zoom = 2;
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
assetManager = new AssetManager();
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
assetManager.load(MAP_ORTHO, TiledMap.class);
assetManager.load(MAP_ISO, TiledMap.class);
assetManager.load(MAP_ISO_STAG, TiledMap.class);
assetManager.load(MAP_HEX_X, TiledMap.class);
assetManager.load(MAP_HEX_Y, TiledMap.class);
assetManager.finishLoading();
map = assetManager.get(MAP_ORTHO);
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextAreaTest2 method render.
@Override
public void render() {
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
Gdx.app.log("X", "FPS: " + Gdx.graphics.getFramesPerSecond());
SpriteBatch spriteBatch = (SpriteBatch) stage.getBatch();
Gdx.app.log("X", "render calls: " + spriteBatch.totalRenderCalls);
spriteBatch.totalRenderCalls = 0;
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextureAtlasTest method create.
public void create() {
batch = new SpriteBatch();
renderer = new ShapeRenderer();
atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
jumpAtlas = new TextureAtlas(Gdx.files.internal("data/jump.txt"));
jumpAnimation = new Animation(0.25f, jumpAtlas.findRegions("ALIEN_JUMP_"));
badlogic = atlas.createSprite("badlogicslice");
badlogic.setPosition(50, 50);
// badlogicSmall = atlas.createSprite("badlogicsmall");
badlogicSmall = atlas.createSprite("badlogicsmall-rotated");
badlogicSmall.setPosition(10, 10);
AtlasRegion region = atlas.findRegion("badlogicsmall");
System.out.println("badlogicSmall original size: " + region.originalWidth + ", " + region.originalHeight);
System.out.println("badlogicSmall packed size: " + region.packedWidth + ", " + region.packedHeight);
star = atlas.createSprite("particle-star");
star.setPosition(10, 70);
font = new BitmapFont(Gdx.files.internal("data/font.fnt"), atlas.findRegion("font"), false);
Gdx.gl.glClearColor(0, 1, 0, 1);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean keyUp(int keycode) {
if (keycode == Keys.UP) {
badlogicSmall.flip(false, true);
} else if (keycode == Keys.RIGHT) {
badlogicSmall.flip(true, false);
} else if (keycode == Keys.LEFT) {
badlogicSmall.setSize(512, 512);
} else if (keycode == Keys.DOWN) {
badlogicSmall.rotate90(true);
}
return super.keyUp(keycode);
}
});
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TextureDataTest method create.
public void create() {
spriteBatch = new SpriteBatch();
// texture = new Texture(new PixmapTextureData(new Pixmap(Gdx.files.internal("data/t8890.png")), null, false, true));
texture = new Texture(new FileTextureData(Gdx.files.internal("data/t8890.png"), null, null, false));
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TideMapAssetManagerTest method create.
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, (w / h) * 10, 10);
camera.zoom = 2;
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
assetManager = new AssetManager();
assetManager.setLoader(TiledMap.class, new TideMapLoader(new InternalFileHandleResolver()));
assetManager.load("data/maps/tide/Map01.tide", TiledMap.class);
assetManager.finishLoading();
map = assetManager.get("data/maps/tide/Map01.tide");
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Aggregations