Add Animated objects

2025-06-21 22:18:04 +00:00
parent 3fe96cf1e8
commit 5448116ca5

28
Animated-objects.md Normal file

@ -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}')
```