Doing sprites with .gif images?

Hey. I have been looking at how games do sprites, and have seen 2 ways of sprites being done: using gifs and sprite sheets. I searched the forum for “gif” and it found nothing. Is it possible to use gif images as a sprite sheet? Or is it simply better to just use a sheet?

The script I am currently works on replaces a mesh with another mesh to animate it, according to an array of frames (example: “anim” : 0, 1, 2, 1) referring to the object to be replaced. --Considering just using SolarLune’s script as it does the same thing and is much more refined.

So should I, and can I, use .gif images for sprite animation?
Thanks

@MrPutuLips - I don’t know of a way to extract frames from GIFs myself; Goran’s probably got the right idea about looking for a Python library to load a GIF and push the frames out. Perhaps it would be a format the bge.texture module could use, or perhaps it could output the frames to disk temporarily for the bge.texture module to load.

@Goran - Switching out meshes is a bit more complex than necessary, but it does have benefits. For one thing, without using LibNew(), any UV-coordinate changes affect all duplicate meshes, so spawned objects share animation frames. On the other hand, replacing the mesh can be useful for 3D cell-based animations (if you could imagine sprites in 3D).

EDIT: Currently, I’ve just been using the normal UV sliding function I made, and just using LibNew to make the sprites unique to handle the above problem.

As long as you reference the same structure, this is also true for systems that use texture coordinate data directly.

Actually, there’s even greater flexibility, because you can have global share, and still cherry pick “custom cases” (if necessary), all without any LibNew hacks.

On the other hand, replacing the mesh can be useful for 3D cell-based animations (if you could imagine sprites in 3D).

Never heard of that.

I know of cell shading, which is just a rendering technique applied to 3D models …

Either way: if it works for you, then that’s the way to go.

Animated gifs are not supported by the BGE.

The best bet is (as mentioned already) a texture (of any kind) and you move the UV coordinates of your mesh around.

Search keyword: uv-scroll

Yeah, sharing the animation is useful under some circumstances (like if you have 10000 torches; only one needs logic to animate). But I’m not sure what you mean by “without any LibNew hacks”. If you spawn an object in while the BGE is running, its mesh shares with all other existing instances of the same object, so you’d end up with the same problem as using the built-in Animated Texture. Using LibNew duplicates the mesh internally so that mesh manipulations like UV animation won’t affect other instances of the same mesh.

I just wanted to know what you meant by that. :slight_smile:

Oh, for some reason I thought you were talking about the coordinate data itself, which defines the frames, and how that structure is shared between different objects.

I think I understand now, and yes, for that you would need a unique mesh.

So I’ve been going through the different methods you described and unpacking .gif images into sprite sheets. Both texture scrolling and replacing the mesh with LibLoad and LibNew work very well.

Thanks :slight_smile: