sprite animation

Blitz3D Forums/Blitz3D Programming/sprite animation

I have a large PNG file of an explosion and I want to use this as an animated sprite. I don't understand how to do this.

How do you figure out the frames? Is there a tutorial?

-RZ

I think you can use the loadanimtexture command. (with createsprite rather than loadsprite).

I think I am still being vague. I got an image that is a series of frames but IS NOT ANIMATED. There are 9 images toto like this:
1 2 3
4 5 6
7 8 9

And those 9 images make up one BIG picture. I know that there is a way to load parts of the image as frames of an animated sprite but I can't remember where I have see that before. Has anyone seen this example?
-RZ

I thought jfk answered your question...

But its the how to get the sprite to flip between frams that has me boggled.

I can get the image to load and animate like this:
Graphics3D 800,600,16,2
SetBuffer BackBuffer()
campivot = CreatePivot()
cam = CreateCamera(campivot)
MoveEntity cam,0,0,-5

flame = LoadAnimImage("textures\flame.png",64,64,0,16)

While Not KeyDown(1)



; The next statment checks to see if 100 milliseconds has passes since we 
; last changed frames. Change the 100 to higher and lower values to 
; make the animation faster or slower. 
If MilliSecs() > tmrSparks + 25 Then 
tmrSparks=MilliSecs() ; 'reset' the timer 
frmSparks=( frmSparks + 1 ) Mod 16; increment the frame, flip to 0 if we are out 
End If 
DrawImage flame,300,300,frmSparks ; draw the image

; updateworld
; renderworld


Flip


Wend
End
But notice that updateworld and renderworld are REM out... I don't see the image if they are left in.

I am trying to make a torch.

-RZ

; LoadAnimTexture Example //modified to use a sprite instead
; ----------------------- 

Graphics3D 640,480 
SetBuffer BackBuffer() 

camera=CreateCamera() 

light=CreateLight() 
RotateEntity light,90,0,0 

cube=CreateSprite() 
PositionEntity cube,0,0,5 

; Load anim texture 
anim_tex=LoadAnimTexture( "pack1.png",49,64,64,0,39 ) 

While Not KeyDown( 1 ) 

; Cycle through anim frame values. 100 represents delay, 39 represents no. of anim frames 
frame=MilliSecs()/100 Mod 39 

; Texture cube with anim texture frame 
EntityTexture cube,anim_tex,frame 

pitch#=0 
yaw#=0 
roll#=0 

If KeyDown( 208 )=True Then pitch#=-1 
If KeyDown( 200 )=True Then pitch#=1 
If KeyDown( 203 )=True Then yaw#=-1 
If KeyDown( 205 )=True Then yaw#=1 
If KeyDown( 45 )=True Then roll#=-1 
If KeyDown( 44 )=True Then roll#=1 

TurnEntity cube,pitch#,yaw#,roll# 

RenderWorld 
Flip 

Wend 

End  


When you use DrawImage, you are not using a sprite, you are simply drawing the image directly to the current buffer.

Yeah I finally found that in the codebase... Works OK...