CAAT.ActorContainer
A CAAT.Foundation.ActorContainer instance, is a container for other Actors including other CAAT.ActorContainers instances. Its main responsibility is to contain and manage other Actors.
It will compound every operation hierarchically for itslef and its children so that it will compose its transformations to all of its contained Actors, and that it will animate, paint and destroy its children when necessary.
The most special kind of ActorContainer are CAAT.Foundation.Director and CAAT.Foundation.Scene objects. Setting a transformation on the Scene means it will be applied for every contained actor, as it happens for example when switching from scene to scene with Director's built-in methods.
CAAT.Foundation.ActorContainer polimorphically extendsClass CAAT.Foundation.Actor.
While treating with ActorContainers, we'll take special attention on Alpha composition. If isGlobalAlpha flag is set, the ActorContainers Alpha value will be set as the reference for all of its children. Otherwise, the alpha value will be set only for this ActorContainer and won't affect any contained children.
function elem( globalAlpha ) { var container = new CAAT.Foundation.ActorContainer(). setSize(180, 180). setFillStyle('red'). setGlobalAlpha( globalAlpha). setAlpha(.33); var circle = new CAAT.Foundation.UI.ShapeActor(). setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE). setFillStyle('green'). setBounds(20, 20, 140, 140); var text= new CAAT.Foundation.UI.TextActor(). setFont("20px arial"). setTextAlign("center"). setTextBaseline("middle"). setText("GlobalAlpha "+(globalAlpha ? "true" : "false")). setLocation( container.width/2, container.height/2 ); container.addChild(circle); container.addChild(text); return container; } var director = new CAAT.Foundation.Director().initialize( 400, 200, document.getElementById('_c9')); // create a vertical gradient to apply to text. var gradient = director.ctx.createLinearGradient(0, 0, 0, director.canvas.height); gradient.addColorStop(0, '#ffff00'); gradient.addColorStop(0.5, '#00ffff'); gradient.addColorStop(1, 'blue'); var scene = director.createScene(). setFillStyle(gradient); director.addScene(scene); var block0= elem(false).setLocation(10,10); var block1= elem(true).setLocation(210,10); scene.addChild(block0); scene.addChild(block1); CAAT.loop(1);