Libgdx Texture Packer !!top!! | Fresh

If you're making a game with libGDX, you will eventually need to draw many images (sprites) on the screen. Loading each image as a separate texture is incredibly inefficient and slow. This is where the Texture Packer comes in. What is the Texture Packer? The Texture Packer is a tool that takes multiple individual image files (PNG, JPG, etc.) and combines them into a single large image, called a Texture Atlas . It also generates a metadata file (usually .atlas ) that tells your game where each original image lives inside that big image.

raw-assets/player/ ├── idle/ │ ├── frame1.png │ └── frame2.png └── run/ ├── run01.png └── run02.png You can access atlas.findRegion("idle/frame1") or atlas.findRegions("run") . libgdx texture packer

// 3. Or get an animated region Animation<TextureRegion> walkAnimation = new Animation<>(0.1f, atlas.findRegions("player_walk"), Animation.PlayMode.LOOP); If you're making a game with libGDX, you

Add the dependency to your core/build.gradle : What is the Texture Packer

dependencies // ... your other dependencies compileOnly "com.badlogicgames.gdx:gdx-tools:$gdxVersion"

// 1. Load the atlas TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("player.atlas")); // 2. Get a single region (a sprite from the atlas) TextureRegion playerStand = atlas.findRegion("player_idle_01");

import com.badlogic.gdx.tools.texturepacker.TexturePacker; public class AssetPacker public static void main(String[] args) TexturePacker.Settings settings = new TexturePacker.Settings(); settings.pot = true; settings.paddingX = 2; settings.paddingY = 2; settings.edgePadding = true; settings.stripWhitespace = true; settings.filterMin = TexturePacker.Settings.TextureFilter.Nearest; settings.filterMag = TexturePacker.Settings.TextureFilter.Nearest;

Share

Search
Početna
Crtići
Filmovi
Epizodni