List of usage examples for com.badlogic.gdx.graphics.g2d TextureAtlas createSprite
public Sprite createSprite(String name)
From source file:CB_UI_Base.GL_UI.Controls.ImageLoader.java
License:Open Source License
private Sprite tryToLoadFromCreatedAtlas(String ImagePath) { if (Atlanten == null) Atlanten = new HashMap<String, TextureAtlas>(); String inputFolder = FileIO.GetDirectoryName(ImagePath); String ImageName = FileIO.GetFileNameWithoutExtension(ImagePath); String Name = getCachedAtlasName(inputFolder); final String AtlasPath = CB_UI_Base_Settings.ImageCacheFolder.getValue() + "/" + Name; if (!FileIO.FileExistsNotEmpty(AtlasPath)) return null; TextureAtlas atlas = null; if (Atlanten.containsKey(AtlasPath)) { atlas = Atlanten.get(AtlasPath); } else {// w ww.j a v a 2s . c om this.AtlasPath = AtlasPath; this.ImgName = ImageName; State = 6; } Sprite tmp = null; if (atlas != null) { tmp = atlas.createSprite(ImageName); } return tmp; }
From source file:CB_UI_Base.GL_UI.Controls.ImageLoader.java
License:Open Source License
void setAtlas(String atlasPath, String imgName, boolean reziseHeight) { State = 7;//from www . j ava2 s . co m TextureAtlas atlas = new TextureAtlas(Gdx.files.absolute(atlasPath)); Atlanten.put(atlasPath, atlas); Sprite tmp = null; if (atlas != null) { tmp = atlas.createSprite(imgName); } if (tmp != null) setSprite(tmp, reziseHeight); }
From source file:CB_UI_Base.GL_UI.Sprites.java
License:Open Source License
protected static Sprite createSprite(TextureAtlas atlas, String name) { Sprite tmp = null;/* www .j a va 2s. c o m*/ if (atlas != null) { tmp = atlas.createSprite(name); } return tmp; }
From source file:com.ads.gps.plane.Assets.java
License:Apache License
private static void createLevels(TextureAtlas atlas) { levels = new ArrayList<Sprite>(); for (int i = 0; i < Integer.MAX_VALUE; i++) { Sprite s = atlas.createSprite("s" + i); if (s == null) { break; }/* w ww. jav a 2s . c om*/ levels.add(s); } }
From source file:com.ads.gps.plane.Assets.java
License:Apache License
private static void loadAd() { try {/*from ww w . j av a 2s .c om*/ seriesList = new ArrayList<Series>(); //???? FileHandle packFile = Gdx.files.external("ads/ad.atlas"); TextureAtlas atlas = new TextureAtlas(packFile); List<Sprite> spriteNames = new ArrayList<Sprite>(); for (int i = 0; i < Integer.MAX_VALUE; i++) { Sprite s = atlas.createSprite("series" + i); if (s == null) { break; } spriteNames.add(s); } FileHandle filehandle = Gdx.files.external("ads/url.txt"); String[] urls = filehandle.readString("UTF-8").split("[#]"); for (int i = 0; i < spriteNames.size(); i++) { String[] url = getUrl(urls, "series" + i).split("[|]"); Series series = new Series().setImage(new Image(spriteNames.get(i))).setName(url[0]) .setDetail(url[1]).setUrl(url[2]); seriesList.add(series); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ads.logic.color.Assets.java
License:Apache License
private static void creteMagicCubes(TextureAtlas atlas) { cubes = new TextureRegion[9]; pieces = new Sprite[9]; for (int i = 0; i < 9; i++) { String name = "piece" + i; pieces[i] = atlas.createSprite(name); cubes[i] = atlas.findRegion(name); }//from w ww . jav a2s . co m }
From source file:com.ads.puzzle.disnep.Assets.java
License:Apache License
private static void creteMagicCubes(TextureAtlas atlas) { cubes = new TextureRegion[4]; pieces = new Sprite[4]; for (int i = 0; i < 4; i++) { String name = "piece" + i; pieces[i] = atlas.createSprite(name); cubes[i] = atlas.findRegion(name); }// ww w . j a va 2s .c om }
From source file:com.ads.puzzle.disnep.Assets.java
License:Apache License
private static void createLevelSprite(TextureAtlas atlas) { SPRITESIZE = Assets.PIECE_SIZE / 3;/*from ww w .ja va 2s . c o m*/ levelSpriteMap = new HashMap<Integer, List<Sprite>>(); for (int i = 0; i < LEVEL_MAX; i++) { List<Sprite> sprites = new ArrayList<Sprite>(); for (int m = 0; m < 5; m++) { String spriteName = String.valueOf((i + 1) * 100 + m); Sprite s1 = atlas.createSprite(spriteName); sprites.add(s1); } levelSpriteMap.put(i, sprites); } }
From source file:com.ads.puzzle.fifa.Assets.java
License:Apache License
private static void createLevelSprite(TextureAtlas atlas) { levelSpriteMap = new HashMap<Integer, List<Sprite>>(); for (int i = 1; i < levelNum; i++) { int m = 0; List<Sprite> sprites = new ArrayList<Sprite>(); while (m < 6) { String spriteName = String.valueOf(i * 100 + m); Sprite s1 = atlas.createSprite(spriteName); if (s1 == null) break; sprites.add(s1);//w w w . j a va 2 s . c o m spriteSize = s1.getHeight(); m++; } levelSpriteMap.put(i - 1, sprites); } }
From source file:com.forerunnergames.peril.client.ui.screens.game.play.modes.classic.playmap.io.loaders.DefaultCountryImagesFactory.java
License:Open Source License
@Override public void create(final PlayMapMetadata playMapMetadata, final ImmutableList<TextureAtlas> countryAtlases) { Arguments.checkIsNotNull(playMapMetadata, "playMapMetadata"); Arguments.checkIsNotNull(countryAtlases, "countryAtlases"); Arguments.checkHasNoNullElements(countryAtlases, "countryAtlases"); log.debug("Creating country images for play map [{}]...", playMapMetadata); destroy();/*w w w . jav a 2s. c o m*/ int atlasIndex = 0; for (final TextureAtlas countryAtlas : countryAtlases) { for (final TextureAtlas.AtlasRegion countryAtlasRegion : countryAtlas.getRegions()) { final ImmutableList<String> regionNameSegments = createRegionNameSegments(countryAtlasRegion, playMapMetadata); final String countryName = createCountryNameFrom(regionNameSegments); final SpriteDrawable countryDrawable = new SpriteDrawable( countryAtlas.createSprite(countryAtlasRegion.name)); if (containsImageState(CountryPrimaryImageState.class, regionNameSegments)) { final CountryPrimaryImageState countryPrimaryImageState = createCountryImageStateFrom( CountryPrimaryImageState.class, regionNameSegments); final CountryPrimaryImage countryPrimaryImage = new CountryPrimaryImage(countryDrawable, countryName, countryPrimaryImageState); countryNamesAndPrimaryImageStatesToPrimaryImages.put(countryName, countryPrimaryImageState, countryPrimaryImage); } else if (containsImageState(CountrySecondaryImageState.class, regionNameSegments)) { final CountrySecondaryImageState countrySecondaryImageState = createCountryImageStateFrom( CountrySecondaryImageState.class, regionNameSegments); final CountrySecondaryImage countrySecondaryImage = new CountrySecondaryImage(countryDrawable, countryName, countrySecondaryImageState); countryNamesAndSecondaryImageStatesToSecondaryImages.put(countryName, countrySecondaryImageState, countrySecondaryImage); } else { invalidCountryImageState(regionNameSegments, countryAtlasRegion, playMapMetadata); } registerCountryAtlasIndex(countryName, atlasIndex); } ++atlasIndex; } for (final String countryName : countryNamesAndPrimaryImageStatesToPrimaryImages.rowKeySet()) { countryNamesToPrimaryImages.put(countryName, new CountryPrimaryImages( ImmutableMap.copyOf(countryNamesAndPrimaryImageStatesToPrimaryImages.row(countryName)), countryNamesToAtlasIndices.get(countryName))); } for (final String countryName : countryNamesAndSecondaryImageStatesToSecondaryImages.rowKeySet()) { countryNamesAndSecondaryImageStatesToSecondaryImages.put(countryName, CountrySecondaryImageState.NONE, new CountrySecondaryImage(null, countryName, CountrySecondaryImageState.NONE)); } for (final String countryName : countryNamesAndSecondaryImageStatesToSecondaryImages.rowKeySet()) { countryNamesToSecondaryImages.put(countryName, new CountrySecondaryImages( ImmutableMap .copyOf(countryNamesAndSecondaryImageStatesToSecondaryImages.row(countryName)), countryNamesToAtlasIndices.get(countryName))); } loadedPlayMapMetadata = playMapMetadata; log.debug("Finished creating country images for play map [{}].", playMapMetadata); }