More on loopsTopImages and Active Objects - putting it all togetherSummary

Summary

We have now seen three different kinds of classes:

  1. Classes that extend WindowController. They require a begin() method to do initialization and may contain methods (such as onMouseClick(Location point)) to respond to mouse events.
  2. Classes that don't extend anything. They require a class constructor (with the same name as the class) to do initialization. They may contain any methods necessary. Examples include Tshirt, Magnet, etc.
  3. Classes that extend ActiveObject. They also require a constructor to do initialization. The last statement of the constructor calls method start(), though you do NOT provide a start method yourself. Instead you must provide a run() method which will eventually be called by start(). Any while loop in execute() must generally include a pause(double) call, both to provide better animation and to allow the processor to handle other processes that desire to run.

Always remember, to create an ActiveObject you:

  1. define a class that "extends ActiveObject"
  2. define its constructor and say "start()" at the end.
  3. define at least a "public void run()" method.
  4. include a pause statement in animation loops in run().

More on loopsTopImages and Active Objects - putting it all togetherSummary