Animated sprites
Animation
An Animation is a named sequence of frames cut from a spritesheet.
walk = (
bf.Animation("walk")
.from_path("hero.png", frame_size=(32, 32))
.set_duration_list([6, 6, 6, 6])
)
Frame durations are tick counts at a 60 FPS base (counter += dt * 60).
Optional callbacks:
set_frame_callback(callback)set_end_callback(callback)
AnimatedSprite
hero = bf.AnimatedSprite(size=(32, 32))
hero.add_animation(walk).set_animation("walk")
hero.set_center(100, 200)
scene.add(hero)
set_animation(name, reset_counter=True, loop=-1, queued_animation=None)loop=-1means infinite- with a finite loop, you can queue another animation when it ends
flipX/flipYproperties- Drawing uses
sprite_rect(anchored relative torect), notrectalone
Debug outlines show both rect and sprite_rect.