Texturepackergui Tools: 1. Tool use: First see the interface of Texturepacker: New Pack: Create Project button, click enter file name, create file. Input directory: Image resource directory to be consolidated, it is recommended to use the input folder in the test me! directory output directory: Integrated image and configuration file save Directory Pack all: package all created Files Name: Configuration file name default image format: defaults to the image formatting: The default image Composition format min page width/height: The width or height of the smallest picture after integration Max page width/ Height: Width or height of the largest picture after integration padding: Margin Alpha threshold: Transparency limit value use steps:
- Click the "New Pack" button, enter the project name, click OK
- To introduce the path to the image to be consolidated at input directory
- In output directory, a consolidated input path is introduced
- In the file configuration area, configure picture margins and more
- Click the Pack All button to wait for the picture to complete.
Textureatlas class: Also known as the Texture Atlas class, mainly responsible for parsing Texturepacker composite images generated after the configuration file. Let's do the actual combat: After the execution, look at the output directory is a profile of the picture information, one is the integration of the image into our project in the assets Directory code as follows: The code in the core:
1 Package Com.mygdx.textureatlas;2 3 import Com.badlogic.gdx.ApplicationAdapter;4 import COM.BADLOGIC.GDX.GDX;5 import com.badlogic.gdx.graphics.GL20;6 import Com.badlogic.gdx.graphics.g2d.Sprite;7 import Com.badlogic.gdx.graphics.g2d.SpriteBatch;8 import Com.badlogic.gdx.graphics.g2d.TextureAtlas;9 /**Ten * Use picture resources One * @author Jack (Le Zhi) A * @blog dtblog.cn - * @qq 984137183 - */ the Public class Maingame extends applicationadapter{ - //declaring sprite brushes - private SpriteBatch batch; - //declaring a map set variable + private Textureatlas Atlas; - //Declaration Wizard + private sprite Sprite; A at @Override -PublicvoidCreate () { - //initializing the sprite brush -Batch=NewSpriteBatch (); - //initializing an Atlas object -atlas=NewTextureatlas ("Packer/myfirst.pack"); in //get test02 Pictures, assign values to sprites -Sprite=atlas.createsprite ("test02"); to + } - the @Override *Publicvoidrender () { $ //Set the white screen backgroundPanax NotoginsengGdx.gl.glClearColor (1, 1, 1, 1); - //Clear Screen the Gdx.gl.glClear (gl20.gl_color_buffer_bit); + //Start Drawing A Batch.begin (); the //Drawing Sprites + Sprite.draw (batch); - batch.end (); $ //End Drawing $ } - -}
Test Class Code:
1 Package Com.mygdx.game.textureatlas;2 3 import com.badlogic.gdx.backends.lwjgl.LwjglApplication;4 import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;5 import Com.mygdx.textureatlas.MainGame;6 7 Public class Test {8 9public staticvoidMain (string[] args) {TenLwjglapplicationconfiguration config=Newlwjglapplicationconfiguration (); One NewLwjglapplication (Newmaingame (), config); A } - -}
Execution effect:
In the configuration file meaning: Alien_jump_: The first line, which represents the picture name, which is the name of the collection object when it gets the picture rotate: Boolean type parameter, determines whether to flip the current picture xy: The starting coordinates of the captured texture picture, such as the starting point (100,20), expressed as "xy:100,20 Size: Texture orig: Anchor offset: Offset index: The original texture number is written by Bo Master Le Zhi Editor, the copyright belongs to the blogger. The original address http://www.dtblog.cn/1152.html reprint please specify the source!
"Open source Java Game Framework Libgdx theme" -12-Development tools-Photo synthesis