Glimmr Canvas Animation

version 1/111030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: Animation callbacks

    A callback is a function that fires once the animation has finished. Callbacks can in principle do anything: start or start another animation track, play a sound, print some text, etc. An animation track can have one or more associated callback routines associated.

    At first glance, the implementation of callbacks in GCA may seem a bit odd, and in fact it is something of an experiment. Rather than assign a rule to be fired, we use a text, stored in the track's "animation-callback" property. At its simplest, this just means that we print a text when the animation completes, e.g.:

        The animation-callback of the default track is "Whew!"
        
    But thanks to a little trick from John Clemens (http://www.math.psu.edu/clemens/IF/I7tricks.html), we can actually invoke standard Inform phrase functions, like so:

         The animation-callback of the default track is "[@ animate the default track as a reel animation targeting the player-avatar at 6 frames per second]".

    The "@" indicates that Inform should read the text substitution that follows as a phrase to be executed. We can chain all this stuff together, e.g.:

        The animation-callback of the default track is "The wheel reverses direction[@ now the image-reel of the Wheel is the reverse-reel][@ animate the default track as a reel animation targeting the Wheel at 8 frames per second]."

    The ability to combine straight printing, "to say" phrases, and standard function phrases in a single statement makes for a compact and flexible approach to callback functions.

    Note that we are bound by the usual restrictions on the content of text substitutions. In particular, they cannot contain commas or brackets of any type, which means that we will need to define intermediary phrases in order to refer to Glimmr coordinates or to provide phrase options, which are separated from their phrase by a comma.