use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TiledMapModifiedExternalTilesetTest 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.position.set(10.0f, 2.5f, 0.0f);
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
// These two maps should appear identical -- a ring of grass with water inside and out.
// The original is correct, without the bug fix to TiledMapTileSets.java that acompanies
// this test, the latter appears as all grass.
// map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_original.tmx");
map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_extended.tmx");
renderer = new IsometricTiledMapRenderer(map, 1f / 32f);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class TiledMapObjectLoadingTest method create.
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, (w / h) * 100, 100);
camera.zoom = 2;
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
map = new TmxMapLoader().load("data/maps/tiled-objects/test-load-mapobjects.tmx");
MapProperties properties = map.getProperties();
shapeRenderer = new ShapeRenderer();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch 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.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class SimpleAnimationTest method create.
@Override
public void create() {
Gdx.input.setInputProcessor(this);
texture = new Texture(Gdx.files.internal("data/animation.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 32, 48);
TextureRegion[] downWalkReg = regions[0];
TextureRegion[] leftWalkReg = regions[1];
TextureRegion[] rightWalkReg = regions[2];
TextureRegion[] upWalkReg = regions[3];
downWalk = new Animation<TextureRegion>(ANIMATION_SPEED, downWalkReg);
leftWalk = new Animation<TextureRegion>(ANIMATION_SPEED, leftWalkReg);
rightWalk = new Animation<TextureRegion>(ANIMATION_SPEED, rightWalkReg);
upWalk = new Animation<TextureRegion>(ANIMATION_SPEED, upWalkReg);
currentWalk = leftWalk;
currentFrameTime = 0.0f;
spriteBatch = new SpriteBatch();
position = new Vector2();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class SoftKeyboardTest method create.
@Override
public void create() {
// we want to render the input, so we need
// a sprite batch and a font
batch = new SpriteBatch();
font = new BitmapFont();
textBuffer = new SimpleCharSequence();
// we register an InputAdapter to listen for the keyboard
// input. The on-screen keyboard might only generate
// "key typed" events, depending on the backend.
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyTyped(char character) {
// convert \r to \n
if (character == '\r')
character = '\n';
// if we get \b, we remove the last inserted character
if (character == '\b' && textBuffer.length() > 0) {
textBuffer.delete();
}
// else we just insert the character
textBuffer.add(character);
return true;
}
});
}
Aggregations