Animation Classes¶
The Animation class¶
-
class
pygame_animations.
Animation
(target, duration[, effect] [, flag=None], **attrs)¶ An animation.
- Parameters
target (object): the object to animate.
duration (int, float): duration of the animation, in seconds.
effect (callable): effect applied to the animation. It can be a native effect or a custom one.
flag (str): used to track the animation. Flags must be alphanumeric and separated by commas.
attrs : properties to animate. To select a sub-property
a.b.c
, usea__b__c
-
target
¶ (Read-only) The object targeted by the animation.
-
duration
¶ (Read-only) Duration of the animation, converted and rounded to millisecondes.
-
start
()¶ Starts the animation. It can only be called once.
- Parameters
None
- Returns
None
-
stop
([noerror=False])¶ Stop the animation and leave the animated object as it is. Once stopped, it cannot be resumed.
- Parameters
noerror (bool): when the method is called on an animation that is not running, ignore if set to
True
or raise aRuntimeError
if set toFalse
.
- Returns
None
-
cancel
([noerror=False])¶ Same as stop(), but put the animated object back in it’s initial state.
- Parameters
noerror (bool): see stop()
- Returns
None
-
fastforward
([noerror=False])¶ Same as stop(), but put the animated object directly in it’s final state.
- Parameters
noerror (bool): see stop()
- Returns
None
-
is_running
()¶ Returns
True
if the animation is running.- Parameters
Aucuns
- Returns
bool
-
can_run
()¶ Returns
True
if the animation hasn’t been started yet.- Parameters
Aucuns
- Returns
bool
-
match
(flags)¶ Returns
True
if the animation’s flags match the given flags.- Parameters
flags (str): the flags to test against, separated by commas. The flag
*
matches anything andflag1|flag2
will match eitherflag1
orflag2
.
- Returns
bool
Note
match() will always return
False
if the animation has no flags
The AnimationSequence class¶
-
class
pygame_animations.
AnimationSequence
(a, b, [*others] [, flag=None])¶ Inherits from
pygame_animations.Animation
Multiple animations run one after another. A sequence can be created by adding animations together :
anim1 + anim2 + anim3
givesAnimationSequence(anim1, anim2, anim3)
- Parameters
a, b and others (Animation): animations of the sequence
flag (str): used to track the animation. Flags must be alphanumeric and separated by commas.
-
animations
¶ (Read-only) The animations of the sequence.
-
duration
¶ (Read-only) The duration of the sequence, equal to the sum of all the animations.
-
start
()¶
-
stop
([noerror=False])¶ Stops the sequence and call stop() on all the animations.
- Parameters
noerror (bool): when the method is called on an animation that is not running, ignore if set to
True
or raise aRuntimeError
if set toFalse
.
- Returns
None
-
cancel
([noerror=False])¶ Same as stop(), but call cancel() on all the animations.
- Parameters
noerror (bool): see stop()
- Returns
None
-
fastforward
([noerror=False])¶ Same as stop(), but call fastforward() on all the animations.
- Parameters
noerror (bool): see stop()
- Returns
None
-
is_running
()¶
-
can_run
()¶
-
match
(flags)¶
The AnimationGroup class¶
-
class
pygame_animations.
AnimationGroup
(a, b, [*others] [, flag=None])¶ Inherits from
pygame_animations.Animation
Multiple animations run together. A group can be created by using the
&
operator between animations :anim1 & anim2 & anim3
givesAnimationGroup(anim1, anim2, anim3)
- Parameters
a, b and others (Animation): the animations of the group
flag (str): used to track the animation. Flags must be alphanumeric and separated by commas.
-
animations
¶ (Read-only) The animations of the group.
-
duration
¶ (Read-only) The duration of the group, equal to the longest duration of the animations.
-
start
()¶
-
stop
([noerror=False])¶ Stops the group and call stop() on all the animations.
- Parameters
noerror (bool): when the method is called on an animation that is not running, ignore if set to
True
or raise aRuntimeError
if set toFalse
.
- Returns
None
-
cancel
([noerror=False])¶ Same as stop(), but call cancel() on all the animations.
- Parameters
noerror (bool): see stop()
- Returns
None
-
fastforward
([noerror=False])¶ Same as stop(), but call fastforward() on all the animations.
- Parameters
noerror (bool): see stop()
- Returns
None
-
is_running
()¶
-
can_run
()¶
-
match
(flags)¶