Reputation: 6745
I am generating animation sequences as my program runs, and I would like the code to just run the sequence one time and then rest. How can I do that?
Here is my code:
window = pyglet.window.Window()
mouth = pyglet.resource.image('pic.png')
raw = pyglet.image.load('pic.png')
raw_seq = pyglet.image.ImageGrid(raw, 1, 7)
animation = pyglet.image.Animation.from_image_sequence(raw_seq, .11, True)
mouth2 = pyglet.sprite.Sprite(animation)
w = window.width
h = window.height
@window.event
def on_draw():
window.clear()
mouth2.draw()
if __name__ == '__main__':
pyglet.app.run()
To clearify: My raw_seq is a list of 7 frames (as I understand it), and I want that sequence to just be animated one time.
Upvotes: 1
Views: 758
Reputation: 71
animation = pyglet.image.Animation.from_image_sequence(raw_seq, .11, False)
that will set loop=False and only run one time
Upvotes: 2