From 5448116ca567429ffea42ae5c320ce33d18d8419 Mon Sep 17 00:00:00 2001 From: Brosef Date: Sat, 21 Jun 2025 22:18:04 +0000 Subject: [PATCH] Add Animated objects --- Animated-objects.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Animated-objects.md diff --git a/Animated-objects.md b/Animated-objects.md new file mode 100644 index 0000000..0f4d35d --- /dev/null +++ b/Animated-objects.md @@ -0,0 +1,28 @@ +# 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: +```python +self.obj = self.createAnimObject('objectID', './path/to/baseFrame.png') +``` + +## To add an animation to it: +```python +self.obj.addAnimation(gameUtils.AnimationHandler('anim1', './path/to/animation.webp', animFPS)) +``` + +## To play an animation: +```python +self.obj.playAnim('anim1') +``` + +## To use events: +```python +# 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}') +``` \ No newline at end of file