Animate Sprites in B3D
Blitz3D Forums/Blitz3D Beginners Area/Animate Sprites in B3D
| ||
I just started learning B3D not too long ago and I can't find a way to animate a sprite. How do you do it? |
| ||
presumably when you say animate a sprite, you mean change the image to another frame? In which case, it isn't a standard blitz thing (unlike LoadAnimImage, there is no LoadAnimSprite). You *could*: 1) Have multiple sprites and switch between them, however each sprite would have a different surface and depending on how many frames you want, this could cause slowdown. 2) (more preferable) use a single surface system and have the animation as one image, and the sprite as a Quad (two triangles). There are many examples of single surface systems in the code archives, some more complex than others (see 3D - Mesh for some of them). |
| ||
LoadAnimTexture? |
| ||
Yeah, just do:sprite = CreateSprite() texture = LoadAnimTexture("tex1.png",32,32,0,10) ; load a 32 x 32 animated texture with 10 frames of animation. Global frame = 0 ; frame of animation EntityTexture sprite,texture,frame Anytime you want to change frame, just do EntityTexture again, but change the frame variable to what frame you want :o) |
| ||
ooops! Bum. I forgot all about that :) |