Load an animated gif

Is it possible to load an animated gif file? I’ve looked at jme java doc and assetManager.loadTexture(params) can load gif extension, but when I try to load a gif file to a geometry it remains static!

Err… You mean animated gif. That requires a different approach, the single images should be side by side in one image and then you use methods similar to the particle emitter. Look for “sprites”, there have been a few implementations for those.

Yes sorry, I mean animated gif [I’ll change the post]. Ok I understand. I was trying to save 2D character animations as animated gifs and than just “load” them with jme. Thanks for your help.

Hi again, I’ve used particle emitter class for animation and all is ok. The only thing that I’m searching for is a method to set x and y for my sprite. I’ve cropped the forward movement of my sprite from its sprite sheet containing all the animations,but this is what I get:

(Left: “stand” texture, no animation only geometry; Right: a frame of the animation with particle emitter)

I’ve tried to modify size of the animation but it remains the same (it’s like a square, while the sprite it’s a rectangle). I also tried to call setShape method, passing an EmitterBoxShape with the right dimensions but the animation disappered! This is the code:

[java]ParticleEmitter animation = new ParticleEmitter(“Forward”, Type.Triangle, 1);

Material material = unshadedMaterial.clone();

Texture texture = assetManager.loadTexture(“SpriteSheets/riku_forward2.PNG”);

material.setTexture(“ColorMap”, texture);






//why only 1 parameter? If I could put x and y values I think it would work








And this is how I tried to change the shape:

[java]animation.setShape(new EmitterBoxShape(Vector3f.ZERO, new Vector3f (0.29f,0.52f,0.01f)));[/java]

Note that the z value is > 0 because the game map has z = 0. Thanks and scuse me if this is a trivial question.

Well the particle emmiter assumes that your if you set 8 images x, that it is exactly size/8 per image, if that is the question?

Yes I think this is the problem, any suggestion to fix it? Another approach is to write the algorithm of animation by myself, but I don’t know how to draw a part of a picture in jme… (with java swing the drawImage method of Graphics2D works fine).

I’ve finally solved my issue! In summary: I wanted to draw animations for 2D character; since there’s no way to play an animated gif, I tried to use Particle Emitter animation, but it assumes that we have squared sprites. In order to change this, I’ve searched a way to draw a part of the sprite sheet ( the current frame of the animation) but I didn’t find methods that allow you to show only a part of the picture (like drawImage in Java, that gives you the possibility of specifying startX, endX, startY,endY parameters of a given image to be drawn, so even irregular sprite sheets were good). So I searched a tool that makes my “irregular” sprite sheets “squared” without resizing the sprites themselves. I found ImageMagick and its mountage command line tool and finally I have squared my sprite sheets and I can use them with Particle Emitter class (I think I’ll write a sort of wrapper for the sprite animation). Useful links:

ImageMagick Homepage http://www.imagemagick.org/script/index.php

Montage Tutorial http://www.imagemagick.org/Usage/montage/

Original Sprite Sheet (Forward animation)

“Squared” Sprite Sheet generated

Thanks for your help.