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 unique virtual timeline for the scene graph.
Note that there can be an undetermned number of directors per browser document. The bad news is that all of them must be using the same rendering technology.
This element will be responsible for many key features including:
- Manage the Scenes.
- Ellegantly switch between any two given scenes.
- Route input events to the proper Actor.
- Manage the main virtual timeline.
- Stablish custom timelines for each Scene.
- Keep reference of the associated canvas (if any).
- Expose the canvas' rendering context as an internal attribute (if any).
- Keep track of resources such as images and sounds.
- 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
- Create the director by specifying at least its dimension.
- Add at least one scene to the director.
- 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.