use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class YDownTest method create.
@Override
public void create() {
// a bitmap font to draw some text, note that we
// pass true to the constructor, which flips glyphs on y
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), true);
// a texture region, note the flipping on y again
region = new TextureRegion(new Texture("data/badlogic.jpg"));
region.flip(false, true);
// a texture atlas, note the boolean
atlas = new TextureAtlas(Gdx.files.internal("data/pack"), true);
// a sprite, created from a region in the atlas
sprite = atlas.createSprite("badlogicsmall");
sprite.setPosition(0, 0);
// a sprite batch with which we want to render
batch = new SpriteBatch();
// a camera, note the setToOrtho call, which will set the y-axis
// to point downwards
camera = new OrthographicCamera();
camera.setToOrtho(true);
// a stage which uses our y-down camera and a simple actor (see MyActor below),
// which uses the flipped region. The key here is to
// set our y-down camera on the stage, the rest is just for demo purposes.
stage = new Stage();
stage.getViewport().setCamera(camera);
image = new MyActor(region);
image.setPosition(100, 100);
stage.addActor(image);
// finally we write up the stage as the input process and call it a day.
Gdx.input.setInputProcessor(stage);
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class FreeTypeMetricsTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
atlas = new TextureAtlas("data/pack");
smallFont = new BitmapFont();
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 60;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
font = generator.generateFont(parameter);
generator.dispose();
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class ParticleEffectLoader method getDependencies.
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, ParticleEffectParameter param) {
Array<AssetDescriptor> deps = null;
if (param != null && param.atlasFile != null) {
deps = new Array();
deps.add(new AssetDescriptor<TextureAtlas>(param.atlasFile, TextureAtlas.class));
}
return deps;
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class SkinLoader method loadSync.
@Override
public Skin loadSync(AssetManager manager, String fileName, FileHandle file, SkinParameter parameter) {
String textureAtlasPath = file.pathWithoutExtension() + ".atlas";
ObjectMap<String, Object> resources = null;
if (parameter != null) {
if (parameter.textureAtlasPath != null) {
textureAtlasPath = parameter.textureAtlasPath;
}
if (parameter.resources != null) {
resources = parameter.resources;
}
}
TextureAtlas atlas = manager.get(textureAtlasPath, TextureAtlas.class);
Skin skin = new Skin(atlas);
if (resources != null) {
for (Entry<String, Object> entry : resources.entries()) {
skin.add(entry.key, entry.value);
}
}
skin.load(file);
return skin;
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class TextureAtlasLoader method load.
@Override
public TextureAtlas load(AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) {
for (Page page : data.getPages()) {
Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class);
page.texture = texture;
}
return new TextureAtlas(data);
}
Aggregations