Glimmr Canvas Animation

version 1/111030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Chapter: Custom animations

    It is also possible to create entirely custom animations, using the "custom" preset. The built-in phrase for custom presets addresses only the interval, duration, and modality (i.e., cycling or randomized) of the track. It does not allow for the specification of a target object, largely because there is no assumption that the "animation" produced will be graphical in nature. Custom tracks can be used for any effect that can be thought of in terms of recurring frames, and in fact it is assumed that custom tracks will most likely be used for real-time events that don't involve graphical displays.

    To invoke a custom animation, we can use this phrase:

        animate <track> as a custom animation at <interval> with a duration of <length> frames, <randomized><cycling>
    Or, without specifying a duration:

        animate <track> as a custom animation at <interval>, <randomized><cycling>
    Note that the latter will have a duration of 1 frame by default unless we specify it some other way.
    On its own, our "animate..." phrase will do nothing. We also need to write an animation rule to implement the animation itself. Note that while cycling behavior will be implemented automatically, we would need to write our own randomization logic into our animation rule for the "randomized" option to have any effect (in the vast majority of cases, we will just ignore that option).

    The animation rule belongs to the "animation" rulebook, and is parameterized on the animation track to be animated. In other words, if we have defined a custom animation track called "my anim-track", then we would write our animation rule's preamble like this:

        Animation rule for my anim-track:
    (As with any other rule, of course, we can also attach conditions to the preamble, e.g. "An animation rule for my anim-track when the player carries the gun", or specify "first animation rule..." or "last animation rule..." to influence the rulebook ordering.)

    GCA provides only one rule intended for custom tracks: the "minimal custom animation rule", which serves only to print a simple message to the debugging log. We can delist it if we want to provide our own debugging log print statements (see the extension's source code for examples).

    We can use the phrase "cease animating <track>" to stop our custom track or any other. This will halt the animation immediately and fire its animation-callback, and is useful both for cycling animations and for those which we need to end early for some reason. A quick usage example:

        Animation rule for my anim-track:
            if the player wears the girdle:
                cease animating my anim-track.