![]() ![]() LibGDX’s TexturePacker is nothing short of excellent. I’m not going to delve into the details of how to use the tool, as you can just click the link that I have provided.Īll you need to know for this tutorial, is that I have used it to pack the frames needed for my demonstration of Sprite animation, and, that we can get hold of the frames for that animation as shown in the source code below. Let’s have a look at our create() method and it’s supporting class member variables. TextureAtlas = new TextureAtlas("spritesheet.atlas") // 9.įrames = textureAtlas.findRegions("invader1") // 10.Īnimation = new Animation(1/15f, frames) // 11. When I packed my sprites into a texture atlas, TexturePacker generated a file called spritesheet.atlas. ![]() This file contains all of the information about each sprite frame I packed. ![]() The TextureAtlas class deals with de-serialsing that file and provides us with handy methods to get hold of the frames for a particular sprite, along with other useful information. ![]() On line 9, we create an instance of TextureAtlas, by passing it the path to our spritesheet.atlas file. On line 10, we ask the TextureAtlas for an array of all the AtlasRegions (frames) belonging to the invader1 sprite. As an added bonus, because of the way I configured TexturePacker, we receive them in animation order. Note that AtlasRegion has the same parent class as Sprite - TextureRegion, which we have seen before. The Animation class makes it a breeze to animate our sprites.įor our purposes, each AtlasRegion holds a frame of animation for our sprite. On line 11, we create a new Animation instance and instruct it to animate our sprite frames 15 times per second. In other words, the duration between each frame is 1/15 seconds, or, 0.0666 seconds. To help cycle the animation frames, in our update() method we utilise a variable which accumulates the delta time between frames - animationStateTime. When it is time to render our sprite, we ask our Animation instance for the frame that we need to draw - AKA the Key Frame. We do this by passing it the current value of our animationStateTime variable. You can see this happening on line 6 below.My issue has been resolved! And yes, as we all suspected, I am an idiot and overlooked something very basic. It ran, reported no errors, and created no output, because my input directory was filled with. Textures Atlas (Sprite Sheet) Is a file containing images that are loaded into memory for performance. Hi! I know there have been threads about this before, but none in the last 3 or 4 months, and none that help my problem. NOTE: The Texture Atlas MUST be placed in android asset file (if android version is being used as Android requires assets to be within application structure so reference can be generate for the R file. I've tried a bunch of things so far, so I can share what I've learned so far, and maybe someone can figure out what I'm doing wrong. The problem: libGDX comes bundled with a TexturePacker. When I try to use it, my Eclipse console says: MyTexturePacker C:\Program Files\Java\jre1.8.0_40\bin\javaw.exe (Jul 3, 2015, 12:56:04 PM)īut no changes are made to my file system. ![]()
0 Comments
Leave a Reply. |