The Essential Guide to HTML5

(Greg DeLong) #1

CANNONBALL AND SL INGSHOT


Function Invoked By / Called By Calls


change Invoked by action of the setInterval function
called in finish


drawall, calls the moveit method of
cball, which is moveball.

Ball Invoked directly by code in a var statement


Myrectangle Invoked directly by code in a var statement


drawball Invoked by call of the draw method for the one
Ball object


drawrects Invoked by call of the draw method for the
target object


moveball Invoked by call of the moveit method for the
one Ball object


Picture Invoked directly by code in var statements


drawAnImage Invoked by call of the draw method for a
picture object


Sling Invoked directly by code in var statements


drawsling Invoked by call of the draw method for mysling


Table 4-6 shows the code for the slingshot application, with the new or changed lines commented. Notice
that the form is absent from the body element. Before looking at the code, try to identify what parts will be
the same as in the cannonball application and what would be different.

Table 4-6. The Slingshot Application

Code Explanation




Slingshot pulling back