CAAT.Scene

The CAAT.Scene object is the main container of animation Actors in a Scene. It is an advanced ActorContainer which has two main responsibilities:

  1. Knows how to elegantly get out of screen
  2. Maintain a virtual timeline for all its contained Actors fed by a Director.

An Scene can not contain neither other Scenes, nor any Director. The size of the scene will by default be the same of the Director, and hence, equals to the Canvas size, that is, the values passed to director's initialize method. The canvas size may vary with the window resize listener thought.

There are two ways of creating an scene:

  1. Manually, by calling var scene= new CAAT.Scene() and then adding it to the director by calling director.addScene(scene);.
  2. The recommended way which is call director.createScene() which also adds the scene to the director instance.

The only method the devloper should call directly on Scene instances is addChild(actor) which adds a new animation Actor to the Scene. It can be any kind of ActorContainer or Actor.

There's no limitation regarding the number of elements in an Scene, but for better performance, the developer should create groups of actors in containers, as if they where in layers. The performance hit is strictly on event dispatching to Scene Actors, since the event bubbling will try to check for every Actor in a Container (or Scene) if it is the target of a concrete event.

The Actors on a Scene will keep z-order equally to the same order as they were added to the Scene/ActorContainer, so the last added Actor, will be behind all the other Actors.