Clone
2
Animated objects
Brosef edited this page 2025-06-21 22:20:40 +00:00

Animated objects

An animated object is a game object that has the ability to hold animations that can be easily played.

To create an animated object:

self.obj = self.createAnimObject('objectID', './path/to/baseFrame.png')

To add an animation to it:

self.obj.addAnimation(gameUtils.AnimationHandler('anim1', './path/to/animation.webp', animFPS))

To play an animation:

self.obj.playAnim('anim1')

To use the events:

# The onEvent function in your Game object
def onEvent(self, event):
    if event.type == gameUtils.AnimStart:
        print(f'Animation {event.animationID} just started on object {event.objectID}')
    elif event.type == gameUtils.AnimStop:
        print(f'Animation {event.animationID} just stopped on object {event.objectID}')