Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.26 KB

animation.rst

File metadata and controls

52 lines (36 loc) · 1.26 KB

Animation

This is a simple animation tool, allowing individual frame files to be composed into a sprite animation, like so:

import ppb
from ppb.features.animation import Animation

class MySprite(ppb.Sprite):
    image = Animation("sprite_{1..10}.png", 4)

Multi-frame files, like GIF or APNG, are not supported.

Pausing

Animations support being paused and unpaused. In addition, there is a "pause level", where multiple calls to :pypause cause the animation to become "more paused". This is useful for eg, pausing on both scene pause and effect.

import ppb
from ppb.features.animation import Animation

class MySprite(ppb.Sprite):
    image = Animation("sprite_{1..10}.png", 4)

    def on_scene_paused(self, event, signal):
        self.image.pause()

    def on_scene_continued(self, event, signal):
        self.image.unpause()

    def set_status(self, frozen):
        if frozen:
            self.image.pause()
        else:
            self.image.unpause()

Reference

ppb.features.animation.Animation