List of usage examples for com.badlogic.gdx.graphics.g2d TextureAtlas TextureAtlas
public TextureAtlas(TextureAtlasData data)
From source file:at.therefactory.jewelthief.JewelThief.java
License:Open Source License
@Override public void create() { instance = this; FreeTypeFontGenerator generator = new FreeTypeFontGenerator( Gdx.files.internal("fonts/amiga4ever pro2.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 8;// w w w. j a v a2 s. c o m parameter.mono = true; font = generator.generateFont(parameter); generator.dispose(); batch = new SpriteBatch(); shapeRenderer = new ShapeRenderer(); camera = new OrthographicCamera(); viewport = new FitViewport(WINDOW_WIDTH, WINDOW_HEIGHT, camera); camera.position.set(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 0); camera.update(); textureAtlas = new TextureAtlas("textures.pack"); assetManager = new AssetManager(); fade = textureAtlas.createSprite("fade"); fade.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); fade.setPosition(0, 0); particles = new Particles(textureAtlas); loadInitialPreferences(); loadAssets(); tryToSubmitLatestHighscores(); // load and show logo screen theRefactoryLogoScreen = new LogoScreen(batch, shapeRenderer, viewport, camera); setScreen(theRefactoryLogoScreen); }
From source file:aurelienribon.texturepackergui.Canvas.java
License:Apache License
@Override public void render() { if (previousPageRequested) { previousPageRequested = false;//from ww w .j a v a2 s . c o m index = index - 1 < 0 ? sprites.size() - 1 : index - 1; } if (nextPageRequested) { nextPageRequested = false; index = index + 1 >= sprites.size() ? 0 : index + 1; } if (packReloadRequested) { packReloadRequested = false; index = 0; camera.position.set(0, 0, 0); camera.update(); sprites.clear(); if (atlas != null) atlas.dispose(); if (packFile != null && packFile.exists()) { try { atlas = new TextureAtlas(packFile); List<Texture> textures = new ArrayList<Texture>(); for (AtlasRegion region : atlas.getRegions()) { if (!textures.contains(region.getTexture())) textures.add(region.getTexture()); } for (Texture tex : textures) { Sprite sp = new Sprite(tex); sp.setOrigin(sp.getWidth() / 2, sp.getHeight() / 2); sp.setPosition(-sp.getOriginX(), -sp.getOriginY()); sprites.add(sp); } } catch (GdxRuntimeException ex) { atlas = null; sprites.clear(); callback.atlasError(); } } } // Render Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); float tw = bgTex.getWidth(); float th = bgTex.getHeight(); batch.getProjectionMatrix().setToOrtho2D(0, 0, w, h); batch.begin(); batch.disableBlending(); batch.draw(bgTex, 0f, 0f, w, h, 0f, 0f, w / tw, h / th); batch.enableBlending(); batch.end(); batch.setProjectionMatrix(camera.combined); batch.begin(); if (!sprites.isEmpty()) sprites.get(index).draw(batch); batch.end(); batch.getProjectionMatrix().setToOrtho2D(0, 0, w, h); batch.begin(); font.setColor(Color.WHITE); lblNextPage.draw(batch); lblPreviousPage.draw(batch); infoLabel.draw(batch); if (sprites.isEmpty()) font.draw(batch, "No page to show", 10, 65); else font.draw(batch, "Page " + (index + 1) + " / " + sprites.size(), 10, 65); font.draw(batch, String.format(Locale.US, "Zoom: %.0f %%", 100f / camera.zoom), 10, 45); font.draw(batch, "Fps: " + Gdx.graphics.getFramesPerSecond(), 10, 25); batch.end(); }
From source file:CB_UI.GL_UI.Views.splash.java
License:Open Source License
@Override protected void Initial() { GL.that.RestartRender();//from w ww .j av a 2s .c om switcher = !switcher; if (switcher && !breakForWait) { // in jedem Render Vorgang einen Step ausfhren switch (step) { case 0: atlas = new TextureAtlas(Gdx.files.internal("skins/default/day/SplashPack.spp")); setBackground(new SpriteDrawable(atlas.createSprite("splash-back"))); break; case 1: ini_Progressbar(); progress.setProgress(10, "Read Config"); break; case 2: ini_Config(); progress.setProgress(15, "Load Translations"); break; case 3: ini_Translations(); progress.setProgress(20, "Load Sprites"); break; case 4: ini_Sprites(); progress.setProgress(30, "check directoiries"); break; case 5: ini_Dirs(); progress.setProgress(40, "Select DB"); break; case 6: ini_SelectDB(); progress.setProgress(60, "Load Caches"); break; case 7: ini_CacheDB(); progress.setProgress(80, "initial Map layer"); break; case 8: ini_MapPaks(); progress.setProgress(100, "Run"); break; case 100: ini_TabMainView(); break; default: step = 99; } step++; } if (step <= 100) resetInitial(); }
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 ww w . ja v a 2 s . c o 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 void setPath(CB_Skin skin) { if (Gdx.gl != null) { Gdx.gl.glFlush();/*from w w w .j av a2s.com*/ Gdx.gl.glFinish(); } String TexturName = CB_UI_Base_Settings.useMipMap.getValue() ? "UI_IconPack_MipMap.spp" : "UI_IconPack.spp"; FileHandleCustomAtlas = null; FileHandleCustomNightAtlas = null; SkinSettings skinSet = skin.getSettings(); if (skinSet.SkinFolder.type() == FileType.Absolute) { FileHandleCustomAtlas = Gdx.files.absolute(skinSet.SkinFolder + "/day/" + TexturName); FileHandleCustomNightAtlas = Gdx.files.absolute(skinSet.SkinFolder + "/night/" + TexturName); } else { FileHandleCustomAtlas = Gdx.files.internal(skinSet.SkinFolder + "/day/" + TexturName); FileHandleCustomNightAtlas = Gdx.files.internal(skinSet.SkinFolder + "/night/" + TexturName); } FileHandleDefaultAtlas = Gdx.files.internal(skinSet.DefaultSkinFolder + "/day/" + TexturName); FileHandleDefaultNightAtlas = Gdx.files.internal(skinSet.DefaultSkinFolder + "/night/" + TexturName); if (atlasDefault != null) { atlasDefault.dispose(); atlasDefault = null; } if (atlasDefaultNight != null) { atlasDefaultNight.dispose(); atlasDefaultNight = null; } if (atlasCustom != null) { atlasCustom.dispose(); atlasCustom = null; } if (atlasCustomtNight != null) { atlasCustomtNight.dispose(); atlasCustomtNight = null; } atlasDefault = new TextureAtlas(FileHandleDefaultAtlas); atlasDefaultNight = new TextureAtlas(FileHandleDefaultNightAtlas); if (!FileHandleDefaultAtlas.equals(FileHandleCustomAtlas)) { try { atlasCustom = new TextureAtlas(FileHandleCustomAtlas); } catch (Exception e) { Log.err(log, "Load Custom Atlas", e); } try { atlasCustomtNight = new TextureAtlas(FileHandleCustomNightAtlas); } catch (Exception e) { Log.err(log, "Load Custom Night Atlas", e); } } }
From source file:com.ads.gps.plane.Assets.java
License:Apache License
private static void loadAd() { try {/*from w w w. j a v a 2 s . c o m*/ 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.puzzle.fifa.Assets.java
License:Apache License
public static void load() { TextureAtlas atlas = new TextureAtlas("p.atlas"); loadBmps(atlas);// w w w .j a v a2 s .com createLevels(atlas); createLevelSprite(atlas); creteMagicCubes(atlas); initConstants(); }
From source file:com.ahsgaming.valleyofbones.TextureManager.java
License:Apache License
public Sprite getSpriteFromAtlas(String atlas, String name, int id) { if (!atlases.containsKey(atlas)) { atlases.put(atlas, new TextureAtlas(Gdx.files.internal(atlas + "-" + size + ".atlas"))); for (Texture t : atlases.get(atlas).getTextures()) { t.setFilter(defaultMinFilter, defaultMaxFilter); }/*from w ww.jav a 2 s.c om*/ } if (id == -1) return atlases.get(atlas).createSprite(name); return atlases.get(atlas).createSprite(name, id); }
From source file:com.ahsgaming.valleyofbones.TextureManager.java
License:Apache License
public Array<Sprite> getSpritesFromAtlas(String atlas, String name) { if (!atlases.containsKey(atlas)) { atlases.put(atlas, new TextureAtlas(Gdx.files.internal(atlas + "-" + size + ".atlas"))); for (Texture t : atlases.get(atlas).getTextures()) { t.setFilter(defaultMinFilter, defaultMaxFilter); }//from www . j a v a 2s. c om } return atlases.get(atlas).createSprites(name); }
From source file:com.ahsgaming.valleyofbones.TextureManager.java
License:Apache License
public TextureAtlas getTextureAtlas(String atlas) { if (!atlases.containsKey(atlas)) { atlases.put(atlas, new TextureAtlas(Gdx.files.internal(atlas + "-" + size + ".atlas"))); for (Texture t : atlases.get(atlas).getTextures()) { t.setFilter(defaultMinFilter, defaultMaxFilter); }/* w w w.j av a 2s.com*/ } return atlases.get(atlas); }