Add Animated objects
28
Animated-objects.md
Normal file
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}')
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user