/** 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; }
/** 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; }
@Override public TextureAtlas load (AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) { for (Page page : data.getPages()) { Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class); page.texture = texture; } TextureAtlas atlas = new TextureAtlas(data); data = null; return atlas; }
@Override public TextureAtlas load (AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) { for (Page page : data.getPages()) { Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class); page.texture = texture; } TextureAtlas atlas = new TextureAtlas(data); data = null; return atlas; }
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas" * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is * automatically disposed when the skin is disposed. */ public Skin (FileHandle skinFile) { FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) { atlas = new TextureAtlas(atlasFile); addRegions(atlas); } load(skinFile); }
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas" * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is * automatically disposed when the skin is disposed. */ public Skin (FileHandle skinFile) { FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) { atlas = new TextureAtlas(atlasFile); addRegions(atlas); } load(skinFile); }
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(); }
renderer = new ShapeRenderer(); atlas = new TextureAtlas(Gdx.files.internal("data/pack")); jumpAtlas = new TextureAtlas(Gdx.files.internal("data/jump.txt"));
@Override public void create () { spriteBatch = new SpriteBatch(); atlas = new TextureAtlas("data/pack"); smallFont = new BitmapFont(); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), atlas.findRegion("verdana39"), false); font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false); renderer = new ShapeRenderer(); renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix()); }
@Override public void create () { spriteBatch = new SpriteBatch(); atlas = new TextureAtlas("data/pack"); smallFont = new BitmapFont(); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 60; FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")); font = generator.generateFont(parameter); generator.dispose(); renderer = new ShapeRenderer(); renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix()); }
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); }
tex2 = new TextureAtlas(Gdx.files.internal("data/pack")); font2 = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
@Override public void create () { Preferences pref = Gdx.app.getPreferences("test"); boolean resultb = pref.getBoolean("test"); int resulti = pref.getInteger("test"); shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl")); if (!shader.isCompiled()) throw new GdxRuntimeException(shader.getLog()); mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0)); mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1}); texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true); texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); String params = Gdx.files.internal("data/gwttestparams.txt").readString(); numSprites = Integer.parseInt(params); batch = new SpriteBatch(); positions = new ArrayList<Vector2>(); for (int i = 0; i < numSprites; i++) { positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight())); } sprite = new Sprite(texture); sprite.setSize(64, 64); sprite.setOrigin(32, 32); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); cache = font.newFontCache(); cache.setColor(Color.RED); cache.setText("This is a Test", 0, 0); atlas = new TextureAtlas(Gdx.files.internal("data/pack")); }
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); }
spriteBatch = new SpriteBatch(); atlas = new TextureAtlas("data/particles.atlas");
@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))); }
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);