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