This is going to be a short exercise. The goal of this section is to develop a primary understanding on use of Pyglet for viewing animations. So let's get on with it.
SimpleAnimation.pyfrom the Packt website. Also download the file
SimpleAnimation.gifand place it in a sub-directory
images. The code is illustrated as follows:
1 import pyglet 2 3 animation = pyglet.image.load_animation( 4 "images/SimpleAnimation.gif") 5 6 # Create a sprite object as an instance of this animation. 7 animSprite = pyglet.sprite.Sprite(animation) 8 9 # The main pyglet window with OpenGL context 10 w = animSprite.width 11 h = animSprite.height 12 win = pyglet.window.Window(width=w, height=h) 13 14 # r,g ...