| 1 | import pyglet |
| 2 | |
| 3 | # Import the new codec |
| 4 | import aseprite |
| 5 | |
| 6 | |
| 7 | window = pyglet.window.Window() |
| 8 | batch = pyglet.graphics.Batch() |
| 9 | |
| 10 | # Add image decoders from the loaded codec module. |
| 11 | # This adds support to the image and resource modules. |
| 12 | pyglet.image.codecs.add_decoders(aseprite) |
| 13 | |
| 14 | # You can now load a animation of *.ase type: |
| 15 | image = pyglet.image.load_animation("running.ase") |
| 16 | sprite = pyglet.sprite.Sprite(img=image, x=100, y=100, batch=batch) |
| 17 | sprite.scale = 8 |
| 18 | |
| 19 | |
| 20 | @window.event |
| 21 | def on_draw(): |
| 22 | window.clear() |
| 23 | batch.draw() |
| 24 | |
| 25 | |
| 26 | if __name__ == "__main__": |
| 27 | pyglet.app.run() |
| 28 |