/** 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); } }
/** 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 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; }
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; }
region.originalHeight = rect.originalHeight; atlas.getRegions().add(region);
region.originalHeight = rect.originalHeight; atlas.getRegions().add(region);
int spriteCount = atlas.getRegions().size; sprites = new Array<Sprite>(spriteCount); for (TextureRegion region : atlas.getRegions()) { sprites.add(new Sprite(region));
@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))); }
for (int i = 0; i < loaded.getRegions().size; i++) { final TextureAtlas.AtlasRegion atlasRegion = loaded.getRegions().get(i); compare(atlas, atlasRegion);
public class Player extends Sprite { TextureAtlas textureAtlas; public Player(TextureAtlas atlas) { super(atlas.getRegions().get(0)); textureAtlas = atlas; } public void setTexture(String textureName) { setRegion(textureAtlas.findRegion(textureName))); } }
@Override public String[] getInternalAnimations(AnimationDesc anim) { retrieveSource(anim.source); TextureAtlas atlas = EngineAssetManager.getInstance().getTextureAtlas(anim.source); Array<AtlasRegion> animations = atlas.getRegions(); ArrayList<String> l = new ArrayList<String>(); for (int i = 0; i < animations.size; i++) { AtlasRegion a = animations.get(i); if (!l.contains(a.name)) l.add(a.name); } return l.toArray(new String[l.size()]); }
/** 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 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; }
/** Updates the {@link TextureAtlas}, adding any new {@link Pixmap} instances packed since the last call to this method. This * can be used to insert Pixmap instances on a separate thread via {@link #pack(String, Pixmap)} and update the TextureAtlas on * the rendering thread. This method must be called on the rendering thread. After calling this method, disposing the packer * will no longer dispose the page pixmaps. */ public synchronized void updateTextureAtlas (TextureAtlas atlas, TextureFilter minFilter, TextureFilter magFilter, boolean useMipMaps) { updatePageTextures(minFilter, magFilter, useMipMaps); for (Page page : pages) { if (page.addedRects.size > 0) { for (String name : page.addedRects) { PixmapPackerRectangle rect = page.rects.get(name); TextureAtlas.AtlasRegion region = new TextureAtlas.AtlasRegion(page.texture, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); if (rect.splits != null) { region.splits = rect.splits; region.pads = rect.pads; } region.name = name; region.index = -1; region.offsetX = rect.offsetX; region.offsetY = (int)(rect.originalHeight - rect.height - rect.offsetY); region.originalWidth = rect.originalWidth; region.originalHeight = rect.originalHeight; atlas.getRegions().add(region); } page.addedRects.clear(); atlas.getTextures().add(page.texture); } } }
@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); }
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()); }
for(TextureAtlas.AtlasRegion r : touchControlsAtlas.getRegions()) { androidOverlaySkin.add(r.name, r, TextureRegion.class);