Sequencer

The sequencer is a system to make dynamic animations using function callbacks. It allows us to animate anything that can be accesed from Python. It is nesscesary when triying to animate some components of BGECore (e.j: music, sprites, widgets). This module is not intended to replace current Blender Game Engine animation system and should not be used for bones or cinematics.

from core import behavior, key, sequencer

class Grenade(behavior.Object):
        [...]

        def onKeyRelease(self, keys):
                if key.E in keys: sequencer.Wait(5, self.expolde)
                [...]

        def explode(self):
                print("KABUUM!")

Callbacks are stored either in module.low_frequency_callbacks or module.height_frequecy_callbacks. The default frquency of those are 10Hz and 50Hz.

class core.sequencer.Wait(time, callback)

Waits a certain amount of time, then calls the callback function.

Parameters:
  • time (float) – The amount of time to wait in seconds.
  • callback (function) – The function to call once it ends.
x

The time since the effect started, in seconds.

Type:float
delete()

Deletes/Stops the effect. Automatically called once x >= time.

class core.sequencer.LinearInterpolation(A, B, time, callback, final=None, transform=False)

Makes a linear interpolation over time, uses a callback to apply changes.

Parameters:
  • A (float) – The start value.
  • B (float) – The end value.
  • time (float) – The time it takes, in seconds.
  • callback – The function to call to apply changes, its first argument will be the value of the interpolation (A <= value <= B).
  • final – The function to call when the interpolation ends.
  • transform (bool) – If True a hight_frequecy_callback will be used.
x

The time since the interpolation started, in seconds.

Type:float
delete()

Deletes/Stops the interpolation. Automatically called once x >= time.

class core.sequencer.AlphaFade(obj, A, B, xtime, ytime, mtime=0, xcallback=None, mcallback=None, ycallback=None)

Makes a object fadeIn, wait, and fadeOut.

Parameters:
  • obj – The object at wich apply the effect.
  • A (float) – On the LinearInterpolation, A->A when fadein, A->B when fadeout.
  • B (float) – On the LinearInterpolation, B->B when fadein, B->A when fadeout.
  • xtime (float) – The time it takes, in seconds for the fadein.
  • ytime (float) – The time it takes, in seconds for the fadeout.
  • mtime (float) – The time to wait in between.
  • xcallback – The function to call when fadein ends.
  • mcallback – The function to call when fadeout starts.
  • ycallback – The function to call when fadeout ends.
x

The time since the effect started, in seconds.

Type:float
xchange(x)

The callback that changes the color of the object. If the class is extended, this method can be overwritten to modify any property.

delete()

Deletes/Stops the effect. Automatically called once x >= xtime+mtime+ytime.