frame advice
BlitzPlus Forums/BlitzPlus Beginners Area/frame advice
| ||
| Hi all... like to know a bit about the drawimage command in respect of frames and how to use them also fonts and how they are used to replace in program txt any help would be very much appreciated |
| ||
| To use frames you need to load an image using LoadAnimImage and specify the frame sizes etc Then use Drawimage image, x, y, frameno LoadAnimImage( filename,width,height,first,count[,flags] ) Parameters filename - string designating full path and filename to image. width - width in pixels of each frame in the image. height - height in pixels of each frame in the image. first - the frame to start with (usually 0) count - how many frames you are using of the imagestrip flags - optional image flags
; Drawimage example
Graphics 800,600
SetBuffer BackBuffer()
; create an image 32 x 32 and call it single_image.png
; save it in the same folder as this code file
Global single_image = LoadImage("single_image.png")
; create an image 160 x 32, save it as theanim_image.png in the same folder as this source file
; we will load it as an anim image that has 5 frames 32 pixels wide and 32 pixels high
; format is loadanimimage(<the image filename>, <width of the frame>, <height of the frame>, <index of the first frame>, <no of frames>)
Global anim_image = LoadAnimImage("theanim_image.png", 32, 32, 0, 5)
Global NoOfFrames = 4
; uncomment the timer code below to slow down the animation
Global Timer% = MilliSecs()
While Not KeyHit(1)
Time% = MilliSecs() - Timer%
Cls
; draw a standard image
DrawImage single_image, 10, 10
; draw image that has been loaded with LoadAnimImage
DrawImage anim_image, 52, 10, NoOfFrames
If Time% >= 500
; cycle through each frame
If NoOfFrames = 4
NoOfFrames = 0
Else
NoOfFrames = NoOfFrames + 1
EndIf
Timer% = MilliSecs() ;reset the timer
EndIf
Flip
Wend
|