Category: 2D Overlay
Syntax:
b2dCyclePalette:Void(imageHandle:Int, startIndex:Int, endIndex:Int, speed:Double)
Void
Rotates a range of palette entries continuously, animating the picture.
Takes imageHandle, startIndex and endIndex (the range to rotate, inclusive, given in either order) and speed in palette entries per second - negative rotates the other way.
Returns nothing.
Safe to call every frame. Given the same range it keeps the running phase and simply updates the speed, so the animation continues smoothly instead of freezing at the first entry.
Given a DIFFERENT range it replaces every cycle the new range overlaps, not just an exactly matching one - so a band being widened or narrowed by a slider does not stack up cycles forever. Use b2dAddPaletteCycle for a deliberate second cycle.
Cycling runs on wall-clock time, so it advances at the same rate regardless of frame rate. A long stall is clamped rather than lurching forward.
View detailed documentation online
Local img:Int = b2dLoadIndexedImage("water.png")
If img = 0 Then
Print "Could not load - is it an 8-bit indexed PNG?"
Return 1
EndIf
b2dCyclePalette(img, 16, 31, 8.0) ; 16 entries, 8 per second
While sysQuitRequested() = 0
sysUpdateEvents()
b2dCls()
b2dDrawImage(img, 0, 0)
b2dFlip()
Wend
BambooBasic © 2026 Michael Denathorn