Computers & the Humanities 281

Animation in Revolution

There are several means through which animation may be accomplished in the Revolution environment. We have utilized a number of animations already through the use of hide, show, visual effects, etc. There are, however, more specific commands that may be employed and methods of manipulating particular properties of specific objects to give them the appearance of being animated.

Move

The one command useful for animating objects is move. Using this command allows a person to animate an object and move it smoothly across the card. The syntax of such a command would be similar to move button "play" to 45,125. This would cause the button specified to move smoothly across the card from its current location to the location specified. The button would then have the new location as one of its properties. The speed at which the object moves is determined by the moveSpeed, a number given in pixels per second. By default the moveSpeed is 200, though it may be set to any value between 0 and 65535.

There are several ways to qualify and modify the movement of an object through the move command. Including in 2 seconds or an equally appropriate time interval after the initial command will cause the object to move between the two points in the designated amount of time. This overrides the moveSpeed, whatever its value. One can also reference a list of valid points within a container. The object would then move to each of the given points in the list until the list is exhausted.

Another method that can be employed is to draw a freehand graphic in any shape or form. We can then command an object to move along the path indicated by that graphic with the command move img "rabbit" to the points of graphic "forestPath". This command will cause the object to begin at one end of the freehand graphic line and move along that line to the other end. The speed at which it moves can be determined as above. The guiding graphic can even be hidden and the command will still cause the object to move along that graphic. In this way we can quickly cause an object to move along a non-standard path.

Dynamic Properties

Another way of creating an animated object is to change dynamically the properties of that object that affect its appearance. This can be accomplished by using control statements judiciously and setting the properties of objects to appropriate values when certain conditions are met. This applies to all attributes of size, color, font, and location.

For example, one could use the rectangle property of a button to give the appearance of the button growing or shrinking. Knowing that the format of the value of rect for an object is four integers delimited by commas, we could have the right side of the button extend to the right or shrink to the left by either increasing or decreasing respectively the value of the third item in the value of the rect. If this is done within a repeat loop, increasing or decreasing the value incrementally and setting the value during these changes, then the button would be animated. Several of these together could be used as an animated bar graph.

Though the example given above may seem a little mundane, the sky is literally the limit in how one can utilize the ability to set the properties of a particular object to animate it.

Animation Manager

Revolution has the ability to create complex custom animations through a tool entitled the Animation Manager (found under the Tools menu). This is somewhat of an involved process and is beyond the scope of this course. If your curiosity is piqued and you're feeling intrepid, Revolution does offer a short tutorial on the operation of this tool.

Course Schedule
Main Page

Script for the Race

on mouseUp
  repeat with jj = 1 to the number of images
    put the location of image jj into line jj of theseLocs
  end repeat
  put false into aWinner
  repeat until aWinner
    put random(the number of images) into whichOne
    get the loc of image whichOne
    add 10 to item 1 of it
    set the loc of image whichOne to it
    wait 5
    if item 1 of it >= item 1 of the loc of graphic finishLine + 45 then
      put true into aWinner
      put the short name of image whichOne into thisWinner
    end if
  end repeat
  put "And the" && thisWinner && "wins!" into field "winner"
  wait 5 seconds
  repeat with jj = 1 to the number of images
    set the loc of image jj to line jj of theseLocs
  end repeat
  put empty into field "winner"
end mouseUp