Extremely old devices may have degraded performance over 512. Applications must take special care to draw these regions properly. If true, TexturePacker will attempt more efficient packing by rotating images 90 degrees. If true, edge pixels are copied into the padding. If true, half of the paddingX and paddingY will be used around the edges of the packed texture. Use greater values such as 4 or 8 if you’re having artifacts when downscaling your textures. The amount of bleed iterations that should be performed. This prevents filtering artifacts when RGB values are sampled for transparent pixels. If true, RGB values for transparent pixels are set based on the RGB values of the nearest non-transparent pixels. The number of pixels between packed images on the y-axis. The number of pixels between packed images on the x-axis. If true, output pages will have power of two dimensions. Note that this is libgdx’s “minimal” JSON format, so double quotes are optional in most cases. If a setting is not specified for a directory or any parent directory, the default value is used. All settings do not need to be specified, any or all may be omitted. Any settings set in the subdirectory override those set in the parent directory.īelow is a JSON example with every available setting and the default value for each. Each subdirectory inherits all the settings from its parent directory. ConfigurationĮach directory may contain a “pack.json” file, which is a JSON representation of the TexturePacker.Settings class. To avoid subdirectory paths being used in image names in the atlas file, see the flattenPaths setting. To use subdirectories for organization without TexturePacker outputting a set of pages for each subdirectory, see the combineSubdirectories setting. Images that need different per texture settings need to go on separate pages, so should be placed in separate subdirectories. Settings like runtime memory format (RGBA, RGB, etc) and filtering (nearest, linear, etc) are per texture. Subdirectories are also useful to group images with related texture settings. This would cause multiple texture binds to render the game and pause menu instead of just one each. If the images were in a single directory that resulted in more than one page, each page could contain a mix of game and pause menu images. Eg, an application may want to place all the “game” images in a separate directory from the “pause menu” images, since these two sets of images are drawn serially: all the game images are drawn (one bind), then the pause menu is drawn on top (another bind). Otherwise, subdirectories can be used to segregate related images to minimize texture binds. If all images fit on a single page, no subdirectories should be used because with one page the app will only ever perform one texture bind. Images in the same directory go on the same set of pages. If the images in a directory don’t fit on the max size of a single page, multiple pages will be used. For each directory of images TexturePacker encounters, it packs the images on to a larger texture, called a page. Given a directory, it recursively scans for image files. TexturePacker can pack all images for an application in one shot. Note that TexturePacker runs significantly faster with Java 1.7+, especially when packing hundreds of input images. Java -cp runnable-texturepacker.jar .texturepacker.TexturePacker inputDir The TexturePacker class is in the gdx-tools project. If you are using Scene2d Skins, you probably already use Skin Composer and can use its user-friendly interface to add your textures to the Skin’s atlas. If you prefer to pack your textures using a GUI, you can use Texture Packer GUI. It also uses brute force, packing with numerous heuristics at various sizes and then choosing the most efficient result. TexturePacker uses multiple packing algorithms but the most important is based on the maximal rectangles algorithm. It stores the locations of the smaller images so they are easily referenced by name in your application using the TextureAtlas class. libGDX has a TexturePacker class which is a command line application that packs many smaller images on to larger images. Binding the texture is relatively expensive, so it is ideal to store many smaller images on a larger image, bind the larger texture once, then draw portions of it many times. ![]() Import .g2d.In OpenGL, a texture is bound, some drawing is done, another texture is bound, more drawing is done, etc. ![]() Here is an example using the same spritesheet from tutorial 3, remember you need to add it to the Android project assets folder. Instead the better way to perform animations is using the Animation class. This is not the ideal way to perform animation using LibGDX and was done to illustrate how to use a TextureAtlas, not how to perform animation. Back in Tutorial 3 I created a simple animation using a Timer and setting the frame manually from a TextureAtlas.
0 Comments
Leave a Reply. |