public void loadEmitterImages (TextureAtlas atlas, String atlasPrefix) { for (int i = 0, n = emitters.size; i < n; i++) { ParticleEmitter emitter = emitters.get(i); if (emitter.getImagePaths().size == 0) continue; Array<Sprite> sprites = new Array<Sprite>(); for (String imagePath : emitter.getImagePaths()) { String imageName = new File(imagePath.replace('\\', '/')).getName(); int lastDotIndex = imageName.lastIndexOf('.'); if (lastDotIndex != -1) imageName = imageName.substring(0, lastDotIndex); if (atlasPrefix != null) imageName = atlasPrefix + imageName; Sprite sprite = atlas.createSprite(imageName); if (sprite == null) throw new IllegalArgumentException("SpriteSheet missing image: " + imageName); sprites.add(sprite); } emitter.setSprites(sprites); } }
public void loadEmitterImages (TextureAtlas atlas, String atlasPrefix) { for (int i = 0, n = emitters.size; i < n; i++) { ParticleEmitter emitter = emitters.get(i); if (emitter.getImagePaths().size == 0) continue; Array<Sprite> sprites = new Array<Sprite>(); for (String imagePath : emitter.getImagePaths()) { String imageName = new File(imagePath.replace('\\', '/')).getName(); int lastDotIndex = imageName.lastIndexOf('.'); if (lastDotIndex != -1) imageName = imageName.substring(0, lastDotIndex); if (atlasPrefix != null) imageName = atlasPrefix + imageName; Sprite sprite = atlas.createSprite(imageName); if (sprite == null) throw new IllegalArgumentException("SpriteSheet missing image: " + imageName); sprites.add(sprite); } emitter.setSprites(sprites); } }
badlogic = atlas.createSprite("badlogicslice"); badlogic.setPosition(50, 50); badlogicSmall = atlas.createSprite("badlogicsmall-rotated"); badlogicSmall.setPosition(10, 10); System.out.println("badlogicSmall packed size: " + region.packedWidth + ", " + region.packedHeight); star = atlas.createSprite("particle-star"); star.setPosition(10, 70);
public void create () { batch = new SpriteBatch(); batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480)); atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/")); sprite = atlas.createSprite("map"); font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false); Gdx.gl.glClearColor(0, 1, 0, 1); }
public void create () { batch = new SpriteBatch(); sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320); textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320); atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/")); texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true); texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest); setTextureFilter(0); setModeString(); sprite = atlas.createSprite("map"); sprite2 = new Sprite(texture, 0, 0, 855, 480); font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false); Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { mode++; if (mode == filters.length * 2) mode = 0; setTextureFilter(mode / 2); setModeString(); return false; } }); }
@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); }
TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("packedimages/pack.atlas")); AtlasRegion region = atlas.findRegion("imagename"); Sprite sprite = atlas.createSprite("otherimagename");
public void loadEmitterImages (TextureAtlas atlas, String atlasPrefix) { for (int i = 0, n = emitters.size; i < n; i++) { ParticleEmitter emitter = emitters.get(i); if (emitter.getImagePaths().size == 0) continue; Array<Sprite> sprites = new Array<Sprite>(); for (String imagePath : emitter.getImagePaths()) { String imageName = new File(imagePath.replace('\\', '/')).getName(); int lastDotIndex = imageName.lastIndexOf('.'); if (lastDotIndex != -1) imageName = imageName.substring(0, lastDotIndex); if (atlasPrefix != null) imageName = atlasPrefix + imageName; Sprite sprite = atlas.createSprite(imageName); if (sprite == null) throw new IllegalArgumentException("SpriteSheet missing image: " + imageName); sprites.add(sprite); } emitter.setSprites(sprites); } }
public SimpleAnimationLoading() { atlas = new TextureAtlas(Gdx.files.internal("loading/pack")); fg = atlas.createSprite("fg"); fg.setPosition( (Engine.getWidth() - fg.getWidth()) / 2, (Engine.getHeight() - fg.getHeight()) / 2); bg = atlas.createSprite("bg"); bg.setPosition( (Engine.getWidth() - bg.getWidth()) / 2, (Engine.getHeight() - bg.getHeight()) / 2); mask = atlas.createSprite("mask"); mask.setPosition( (Engine.getWidth() - mask.getWidth()) / 2, (Engine.getHeight() - mask.getHeight()) / 2); }