use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class AssetManagerTest method load.
private void load() {
// Gdx.app.setLogLevel(Logger.DEBUG);
start = TimeUtils.nanoTime();
tex1 = new Texture("data/animation.png");
tex2 = new TextureAtlas(Gdx.files.internal("data/pack"));
font2 = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
// tex3 = new Texture("data/test.etc1");
// map = TiledLoader.createMap(Gdx.files.internal("data/tiledmap/tilemap csv.tmx"));
// atlas = new TileAtlas(map, Gdx.files.internal("data/tiledmap/"));
// renderer = new TileMapRenderer(map, atlas, 8, 8);
shader = new ShaderProgram(Gdx.files.internal("data/g2d/batchCommon.vert").readString(), Gdx.files.internal("data/g2d/monochrome.frag").readString());
System.out.println("plain took: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
start = TimeUtils.nanoTime();
manager.load("data/animation.png", Texture.class);
// manager.load("data/pack1.png", Texture.class);
manager.load("data/pack", TextureAtlas.class);
// manager.load("data/verdana39.png", Texture.class);
manager.load("data/verdana39.fnt", BitmapFont.class);
// manager.load("data/multipagefont.fnt", BitmapFont.class);
// manager.load("data/test.etc1", Texture.class);
// manager.load("data/tiledmap/tilemap csv.tmx", TileMapRenderer.class, new
// TileMapRendererLoader.TileMapParameter("data/tiledmap/", 8, 8));
manager.load("data/i18n/message2", I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(reloads % 2 == 0 ? Locale.ITALIAN : Locale.ENGLISH));
manager.load("data/g2d/monochrome.frag", ShaderProgram.class, new ShaderProgramLoader.ShaderProgramParameter() {
{
vertexFile = "data/g2d/batchCommon.vert";
}
});
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas 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.TextureAtlas in project libgdx by libgdx.
the class TextureRegion3DTest method create.
@Override
public void create() {
Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f);
atlas = new TextureAtlas(Gdx.files.internal("data/testpack"));
regions = atlas.getRegions();
modelBatch = new ModelBatch(new DefaultShaderProvider());
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse));
model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
instance = new ModelInstance(model);
attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class GwtTest method create.
@Override
public void create() {
Preferences pref = Gdx.app.getPreferences("test");
boolean resultb = pref.getBoolean("test");
int resulti = pref.getInteger("test");
shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl"));
if (!shader.isCompiled())
throw new GdxRuntimeException(shader.getLog());
mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
mesh.setVertices(new float[] { -0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1 });
texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
String params = Gdx.files.internal("data/gwttestparams.txt").readString();
numSprites = Integer.parseInt(params);
batch = new SpriteBatch();
positions = new ArrayList<Vector2>();
for (int i = 0; i < numSprites; i++) {
positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight()));
}
sprite = new Sprite(texture);
sprite.setSize(64, 64);
sprite.setOrigin(32, 32);
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
cache = font.newFontCache();
cache.setColor(Color.RED);
cache.setText("This is a Test", 0, 0);
atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class APKExpansionTest method create.
@Override
public void create() {
if ((((AndroidFiles) Gdx.files)).setAPKExpansion(1, 0)) {
resolver = new ZipFileHandleResolver();
} else {
Gdx.app.error("libgdx", "No Expansion can be opened");
}
assetManager = new AssetManager();
FileHandleResolver resolver = new InternalFileHandleResolver();
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
loadFont(assetManager, "data/DroidSerif-Regular.ttf", 12);
loadFont(assetManager, "data/" + extensionPrefix + "DroidSerif-Regular.ttf", 12);
assetManager.load("data/" + extensionPrefix + "testpackobb", TextureAtlas.class);
assetManager.finishLoading();
sound = Gdx.audio.newSound(Gdx.files.internal("data/" + extensionPrefix + "chirp.ogg"));
sound.play();
texture = new Texture(resolver.resolve("data/" + extensionPrefix + "badlogic.jpg"));
batch = new SpriteBatch();
TextureAtlas atlas = assetManager.get("data/" + extensionPrefix + "testpackobb");
atlasTextureRegion = new TextureRegion(atlas.findRegion("water"));
sound = Gdx.audio.newSound(Gdx.files.internal("data/shotgun.ogg"));
sound.play();
}
Aggregations