CAAT.Director

The director is the root in the hierarchy of CAAT's components. In its core is a CAAT.ActorContainer instance which manages the scene graph timeline, gives unique timelines for each scene, and handles scene transitions.

Note that there can be more than one director object per browser document. The bad news is that all of them must be using the same rendering technology. So you can't mix a css renderer with a canvas one.

This element will be responsible for many key features including:

  • Manage the Scenes and their transitions.
  • Route input events to the correct Actor.
  • Manage the main timeline, and supply with unique time lines for each scene.
  • Keep track of resources such as images and sounds.
  • Play sounds and music.
  • etc.

The Director object instances try to render frames using requestAnimationFrame. In case there's not such browser functionality, the developer has the opportunity of setting the desired animation quality in the form of frames per second.

The lifecycle of the director will be as follows

  1. Create the director by specifying at least its dimension.
  2. Add at least one scene to the director.
  3. Instrument the engine to start de animation by calling CAAT.loop. It is also possible to start the animation by calling director.loop({number}expexted fps), but this is not the recommended way.