I'm trying to animate a 2D image, I have each of my images cut out into appropriate sizes. However I am not sure how to use the TexturePacker and TextureAtlas to animate them. I looked at the libgdx github tutorial but it does not show how it works. I have each of my seven images in appropriate format such as (image_1,image_2,image_3...etc) as suggested on the tutorial, how do I pack these images and use them with the Atlas? Any code sample would be appreciated
Hey I figured it out guys I'm actually just suppose to pack it with the TexturePacker tool which I had to download its a separate .jar file from here and then execute this lines of code
TextureAtlas atlas;
public Animation<TextureRegion> runningAnimation;
atlas = new TextureAtlas(Gdx.files.internal("directory/pack.atlas"));
runningAnimation = new Animation<TextureRegion>(0.033f,atlas.findRegions("running"), PlayMode.LOOP);
There is an official wiki about animation, TexturePacker+TextureAtlas.
Also, a good tutorial on animation for Libgdx
And tutorial of TexturePacker + Libgdx
Related
I'm new to cocos2d-x game development engine
but I don't understand what is the difference between Atlas and sprite-sheet.
are they the same thing or not?
Atlas is like a generic object if you want to render fast a grouped of images from a single image file like, bitmap labels, spritesheet, multi-image particle, etc.
SpriteSheet is one of those objects that uses functionality of Atlas to render its images fast.
I am trying to use Lottie files with my libGDX game.
I downloaded the files from https://www.lottiefiles.com/
which are downloaded in JSON format but I am unable to figure out or find any tutorial on how to use them.
Is it not possible to use Lottie with libGDX. if not, is there a good animation library like Lottie which can be used with libGDX?
Edits:
It's not just about Lottie, it appears to me that the only was to add animation to libGdx is to use the TexturePacker to pack a set of images into a sprite sheet. Is it not possible to use a pre-made json format textureAtlas for animation?
Currently I am trying to export an animation from Adobe Animate CC as a texture atlas but I can't find anything on how to use it in LibGdx.
I am making a simple game using libgdx. I have a TextureAtlas that has I ninepatch I am trying to use:
The image is saved as menu.9.png
I am using the following code:
Image bg = new Image(Room.iAtlas.findRegion("GUI/menu"));
bg.setBounds(guix-border,guiy-border,(border+radius)*2,(border+radius)*2);
batch.begin();
bg.draw(s,1);
batch.end();
The output is like this:
I really just have no idea what I am doing wrong, but it should be more like this(Except it would have the shapes on top of it, but I didn't add those):
(I created that by hand, i've never actually had 9patch working, and it doesn't have the ships because I didn't bother to edit those in)
It looks like your "nine patch" isn't being treated as a real nine path, and is being treated as a "degenerate" nine patch (I had a very similar problem earlier: Loading nine-patch image as a Libgdx Scene2d Button background looks awful, though I wasn't using a TextureAtlas which is supposed to be the solution.)
Basically, when Libgdx reads the nine-patch out of your atlas, its supposed to read all the meta-data that describes how to chop the image up into 9 tiles (see https://code.google.com/p/libgdx/wiki/TexturePacker#NinePatches). I see a couple places this could go wrong:
Your texture isn't a valid nine-patch, and the meta-data is being ignored. (Check with the Android draw9patch tool.)
Your texture packer isn't processing the .9.png file correctly. Check the contents of the .txt file for your atlas, and see if it has "split" entries associated with the "menu.9.png" entry.
The texture lookup is just returning a regular TextureRegion wrapper for the nine-patch region, and isn't wrapping it in a NinePatch object. Try using TextureRegion.createNinePatch to make that more explicit. (I'm under the impression that this isn't necessary, but maybe it is ...)
I'm new to AS3 and I'm trying to create a simple game with it.
So far, I have been able to draw images like this:
[Embed(source = 'C:/mypath/myimage.png')]
public static var myImageClass:Class;
private var myImage:Bitmap = new myImageClass();
and then render myImage.
but that draws only a picture with no animation.
What I want is to import this picture:
and then cut the image to series of subimages and draw an animation out of them, rather than a single image. How may I do this?
Thanks!
This is called "Blitting". You could accomplish it with fairly decent results, depending on your deployment target and how many animations you require, using BitmapData.copyPixels(), but it's more ideal to use the Starling Framework, which employs Stage3D hardware acceleration.
More here:
Introducing the Starling Framework (Video tutorial)
Starling documentation
What you are looking for is SpriteSheet support. You can easily write this yourself or use existing libraries (like Starling for instance).
The idea is to draw an area of the image at each frame to actually create the animation. Depending on the format of your sprite sheet, you may have to add another file to describe the positions of each rectangle to draw.
This page explains how to implement it.
I export a path from Illustrator to an .swf file. I import this file using the Loader class in actionscript 3.
Now I want to perform a collision test on this path in Flash. Is this possible? Now as3 performs this test on the whole bounds of the swf file. I only need the path. Is this possible?
It works good as long you not use any transparacy effects in Illustrator which you want to export, which not are compatible with swf.
There are two settings in ai exporting non compatible effects to swf file.
Appearance: which will make a bitmap under the swf, which make the hittestarea to a square.
Editability: will remake the effects so good as the can to swf, which should possible still keep the polygon hittestarea, but it didnt work for me.
Yes that's possible. BitmapData.hitTest will help you (take a look at e.g. this)