Sprite Candy Animation Example

Community Forums/Developer Stations/Sprite Candy Animation Example

ryan scott(Posted 2006) [#1]
Is there a *simple* sprite candy animation example somewhere?

just want the bare minimum to get a multiple frame png animating on the screen.

the animation example included has a lot of extra junk in it, i want to know the only lines that are required.

thanks all!


tonyg(Posted 2006) [#2]
Graphics3D 640, 480, 0, 2 : SetBuffer BackBuffer()
; INCLUDE SPRITE CANDY
Include "../sprite candy.bb"
; CREATE CAMERA, LIGHT, BACKGROUND
Cam = CreateCamera()
; CREATE THE HUD
HUD% = HUD_Create (Cam)
; LOAD FONTS & IMAGES
Resource1% = HUD_LoadImageResource ("../Media/image1.png",4) ; <-- BLACK BECOMES TRANSPARENT 
ImageLayer% = HUD_CreateLayer(HUD, Resource1)
; SOME SETTINGS
clip_startx% = 67
clip_starty% = 277
clip_width%  = 38
clip_height% = 62
frame%        = 0   ; CURRENT FRAME (FIRST = 0 HERE)
frame_delay%  = 150 ; MILLISECS
last_change%  = MilliSecs()
; SINGLE ANIMATED IMAGE
Image1% = HUD_CreateImage (ImageLayer, 0,0, 67,277,38,62, "CENTER-100","CENTER+75")
; ------------------------------------------------------------------------
; MAIN LOOP
; ------------------------------------------------------------------------
While Not KeyDown(1)
	now% = MilliSecs()
	; ANIMATION CONTROL
	If now - last_change > frame_delay Then
		last_change = now
		frame = frame + 1 : If frame > 4 Then frame = 0
		HUD_SetImageClip Image1, clip_startx + (frame*clip_width), clip_starty
	End If
	HUD_Update :  RenderWorld : Flip 0
Wend
HUD_RemoveAll True : End



ryan scott(Posted 2006) [#3]
10 minutes to a beautiful answer. this community rocks.
thanks tonyg