Refine search
@Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) { if (parameter != null && parameter.atlasName != null) { TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class); String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString(); AtlasRegion region = atlas.findRegion(name); if (region == null) throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName); return new BitmapFont(file, region); } else { int n = data.getImagePaths().length; Array<TextureRegion> regs = new Array(n); for (int i = 0; i < n; i++) { regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class))); } return new BitmapFont(data, regs, true); } }
spriteBatch = new SpriteBatch(); atlas = new TextureAtlas("data/particles.atlas"); int spriteCount = atlas.getRegions().size; sprites = new Array<Sprite>(spriteCount); for (TextureRegion region : atlas.getRegions()) { sprites.add(new Sprite(region)); effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2); emitters = new Array(effect.getEmitters()); effect.getEmitters().clear(); effect.getEmitters().add(emitters.get(0));
@Override public void dispose () { atlas.dispose(); skin.dispose(); } }
public void setAtlas(TextureAtlas atlas){ if(atlas == this.atlas) return; regionsPanel.removeAll(); Array<AtlasRegion> atlasRegions = atlas.getRegions(); CustomCardLayout layout = (CustomCardLayout)regionsPanel.getLayout(); Array<TextureRegion> regions = new Array<TextureRegion>(); for(Texture texture : atlas.getTextures()){ FileTextureData file = (FileTextureData)texture.getTextureData(); regionsPanel.add(new TexturePanel( texture, getRegions(texture, atlasRegions, regions))); } layout.first(regionsPanel); this.atlas = atlas; }
renderer = new ShapeRenderer(); atlas = new TextureAtlas(Gdx.files.internal("data/pack")); jumpAtlas = new TextureAtlas(Gdx.files.internal("data/jump.txt")); jumpAnimation = new Animation<TextureRegion>(0.25f, jumpAtlas.findRegions("ALIEN_JUMP_")); badlogic = atlas.createSprite("badlogicslice"); badlogic.setPosition(50, 50); 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);
region.originalHeight = rect.originalHeight; atlas.getRegions().add(region); page.addedRects.clear(); atlas.getTextures().add(page.texture);
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); } }
String regionsName = name; for (Texture texture : atlas.getTextures()) { trackedTextures.add(texture); for (AtlasRegion region : atlas.findRegions(regionsName)) { AtlasRegion region = atlas.findRegion(regionName); if (region == null) throw new GdxRuntimeException("Tileset region not found: " + regionName); tile = new StaticTiledMapTile(region); Array<AnimatedTiledMapTile> animatedTiles = new Array<AnimatedTiledMapTile>(); if (animationElement != null) { Array<StaticTiledMapTile> staticTiles = new Array<StaticTiledMapTile>(); IntArray intervals = new IntArray(); for (Element frameElement: animationElement.getChildrenByName("frame")) {
private void fillBGRegions(InputPanel atlasInput, InputPanel regionInput) { @SuppressWarnings("unchecked") FilteredSelectBox<String> cb = (FilteredSelectBox<String>) regionInput.getField(); // cb.clearItems(); cb.getItems().clear(); if (atlas != null) { atlas.dispose(); atlas = null; } if (backgroundAtlas.getText().isEmpty()) { setInfoWidget(new Label(INFO, getSkin())); return; } atlas = new TextureAtlas(Gdx.files.absolute(Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/" + Ctx.project.getResDir() + "/" + atlasInput.getText() + ".atlas")); Array<AtlasRegion> regions = atlas.getRegions(); for (AtlasRegion r : regions) if (cb.getItems().indexOf(r.name, false) == -1) cb.getItems().add(r.name); cb.getList().setItems(cb.getItems()); if (cb.getItems().size > 0) cb.setSelectedIndex(0); cb.invalidateHierarchy(); showBgImage(regionInput.getText()); }
Gdx.app.log("PixmapPackerTest", "Number of initial textures: " + atlas.getTextures().size); textureRegions = new Array<TextureRegion>(); packer.updateTextureRegions(textureRegions, TextureFilter.Nearest, TextureFilter.Nearest, false); Gdx.app.log("PixmapPackerTest", "Number of updated textures: " + atlas.getTextures().size); Gdx.input.setInputProcessor(new InputAdapter() { @Override ninePatch = atlas.createPatch("textfield-1"); officialPatch = skin.getPatch("textfield"); officialPatch.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); TextureAtlas loaded = new TextureAtlas(Gdx.files.local("pixmapPackerTest.atlas")); for (int i = 0; i < loaded.getRegions().size; i++) { final TextureAtlas.AtlasRegion atlasRegion = loaded.getRegions().get(i); compare(atlas, atlasRegion);
/** Adds all named texture regions from the atlas. The atlas will not be automatically disposed when the skin is disposed. */ public void addRegions (TextureAtlas atlas) { Array<AtlasRegion> regions = atlas.getRegions(); for (int i = 0, n = regions.size; i < n; i++) { AtlasRegion region = regions.get(i); String name = region.name; if (region.index != -1) { name += "_" + region.index; } add(name, region, TextureRegion.class); } }
public BigScoreActor(MainGame mainGame) { super(mainGame); Array<TextureAtlas.AtlasRegion> atlasRegions = mainGame.getAtlas().findRegions(Res.Atlas.IMAGE_NUM_BIG_00_TO_09); TextureRegion[] digitRegions = new TextureRegion[atlasRegions.size]; for (int i = 0; i < atlasRegions.size; i++) { digitRegions[i] = atlasRegions.get(i); } setDigitRegions(digitRegions); }
public TextureAtlas getAtlas(Texture texture){ Array<TextureAtlas> atlases = assetManager.getAll(TextureAtlas.class, new Array<TextureAtlas>()); for(TextureAtlas atlas : atlases){ if(atlas.getTextures().contains(texture)) return atlas; } return null; }
@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))); }
@Override public void create() { camera = new OrthographicCamera(); viewport = new FitViewport(SCENE_WIDTH, SCENE_HEIGHT, camera); batch = new SpriteBatch(); animationTime = 0.0f; // Load atlases and textures cavemanAtlas = new TextureAtlas(Gdx.files.internal("data/caveman.atlas")); dinosaurAtlas = new TextureAtlas(Gdx.files.internal("data/trex.atlas")); background = new Texture(Gdx.files.internal("data/jungle-level.png")); // Load animations Array<AtlasRegion> cavemanRegions = new Array<AtlasRegion>(cavemanAtlas.getRegions()); cavemanRegions.sort(new RegionComparator()); Array<AtlasRegion> dinosaurRegions = new Array<AtlasRegion>(dinosaurAtlas.getRegions()); dinosaurRegions.sort(new RegionComparator()); cavemanWalk = new Animation(FRAME_DURATION, cavemanRegions, PlayMode.LOOP); dinosaurWalk = new Animation(FRAME_DURATION, dinosaurRegions, PlayMode.LOOP); // Position the camera camera.position.set(SCENE_WIDTH * 0.5f, SCENE_HEIGHT * 0.5f, 0.0f); }
Gdx.app.log("PixmapPackerTest", "Number of initial textures: " + atlas.getTextures().size); animation = new Animation<TextureRegion>(0.33f, atlas.findRegions("badlogic-anim"), Animation.PlayMode.LOOP); textureRegions = new Array<TextureRegion>(); packer.updateTextureRegions(textureRegions, TextureFilter.Nearest, TextureFilter.Nearest, false); Gdx.app.log("PixmapPackerTest", "Number of updated textures: " + atlas.getTextures().size); Gdx.input.setInputProcessor(new InputAdapter() { @Override ninePatch = atlas.createPatch("textfield-1"); officialPatch = skin.getPatch("textfield"); officialPatch.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
@Override public TextureRegion getImage (String name) { return atlas.findRegion(name); } }
/** Generates a new {@link TextureAtlas} from the pixmaps inserted so far. After calling this method, disposing the packer will * no longer dispose the page pixmaps. */ public synchronized TextureAtlas generateTextureAtlas (TextureFilter minFilter, TextureFilter magFilter, boolean useMipMaps) { TextureAtlas atlas = new TextureAtlas(); updateTextureAtlas(atlas, minFilter, magFilter, useMipMaps); return atlas; }
public void create () { TextureAtlas textureAtlas = new TextureAtlas("data/pack"); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), textureAtlas.findRegion("verdana39"), false); singleLineCache = new BitmapFontCache(font, true); multiLineCache = new BitmapFontCache(font, true); singleLineCacheNonInteger = new BitmapFontCache(font, false); multiLineCacheNonInteger = new BitmapFontCache(font, false); batch = new SpriteBatch(); fillCaches(); }
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); }