LoadAnimTexture ( file$,flags,width,height,first,count )

Parameters

file$ - image file containing the frames
flags - texture flags, added together, as per LoadTexture (1: colour, 2: alpha, 4: masked, 8: mipmapped, ...)
width - width of each frame, in pixels
height - height of each frame, in pixels
first - index of the first frame to grab, starting at 0
count - number of frames to grab

Description

Loads an image and splits it into a multi-frame animated texture, returning the texture handle or 0 on failure.

The image is treated as a grid of width-by-height cells, numbered from 0 left to right, then row by row downwards. Frames first to first+count-1 are grabbed. If the requested frames don't fit inside the image, the load fails and 0 is returned.

The texture doesn't animate by itself: you choose the visible frame wherever you apply it, via the frame parameter of EntityTexture or BrushTexture. Step the frame number in your main loop for flipbook effects - fire, water, blinking signs, sprite sheets on quads.

Unlike LoadTexture's optional flags, the flags parameter is required here. Texture filters that match the filename add their flags on top, as with any loaded texture.

See also: LoadTexture, CreateTexture, EntityTexture, BrushTexture, TextureFilter.

Example

; LoadAnimTexture Example
; -----------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

; A billboard sprite to play the explosion on (sprites always face the camera)
boom=CreateSprite()
ScaleSprite boom,1.25,1
PositionEntity boom,0,0,5

; Full-bright, so the explosion is not darkened by scene lighting
EntityFX boom,1

; Load a 6-frame explosion strip: each frame is 60x48 pixels.
; Flag 4 = masked, so the black background becomes transparent.
boom_tex=LoadAnimTexture("media/kaboom.bmp",4,60,48,0,6)

While Not KeyDown(1)

    ; Advance one animation frame every 100 milliseconds, looping 0-5
    frame=(MilliSecs()/100) Mod 6

    ; Apply the current frame of the anim texture to the sprite
    EntityTexture boom,boom_tex,frame

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrows: camera   Esc: exit"
    Text 0,20,"EntityTexture boom,boom_tex,"+frame+"  (frame "+frame+" of 0-5)"

    Flip

Wend

End

Index