Skip to content
Robert Silverton edited this page Aug 12, 2013 · 7 revisions

Cadet / Cadet Engine / Cadet Library

A library of code implementing a Component based approach to constructing a visual scene. At its core, Cadet is a collection of Components that during run-time form a tree data structure describing a scene and all the objects within it. It is designed to be 'plug and play' - this means that components can be added and removed dynamically from this data structure, and the framework takes care of the wiring.

Cadet Scene

A Cadet Scene is itself a Component, and is always the top-most Component in a hierarchy. It is analogous to the Stage in the context of Flash's display list.

Component

Any object added to a CadetScene hierarchy must be a Component. Much like the DisplayObject class is the base class of any object to be added to Flash’s display list, the Component class serves the same purpose. You do not create an instance of a Component directly; instead you will create instances of other Components that extend this class.

ComponentContainer

A Component that can contain other Components. A ComponentContainer’s children define how it looks and behaves. In much the same way, an empty MovieClip doesn’t really ‘do’ anything by itself, but if you add some graphics and some timeline Actionscript, you have effectively given it a particular look and behaviour. In much the same way you need to instantiate Sprites/Shapes/Movieclips instead of a DisplayObjectContainer, the same is true of ComponentContainers. Currently the only classes extending ComponentContainer are Entity and CadetScene.

Skin

A Component implementing the ISkin interface. This interface doesn’t actually add any methods, instead it works more like a ‘marker’, essentially categorising the component as a ‘Skin’. Skins are responsible for providing the look of a ComponentContainer.

Behaviour

Behaviour Components are responsible for adding behaviour to a ComponentContainer. Typically Behaviours also implement the ISteppableComponent behaviour, as most Behaviours change or animate something per update. However not all Behaviours need to do this – for example a Behaviour may simply alter a property on a sibling Component when added, and revert this property when removed.

Geometry

A Component that implements the IGeometry marker interface. Geometry can be anything from a rectangle to a Bezier curve. It can be seen as the model of the ComponentContainer. Not all ComponentContainers will make use of Geometry. However, any ComponentContainer that wants to have physics simulated on it, or requires some sort of collision detection between itself and another ComponentContainer will need some sort of geometry to define its shape.

Transform

A Component implementing the ITransform interface. There is currently only one concrete implementation of this class, Transform2D. The only other concrete implementation would be a Transform3D class. A Transform Component is responsible for storing the state of a ComponentContainer’s position in space. A ComponentContainer with Geometry and a Skin will not be displayed until you have also added a Transform Component.

Process

Processes are Components that are typically added to the root of a CadetScene and provide top-level ‘managers’, which Components within the scene can hook into. An example of a Process is the KeyboardProcess. Adding keyboard logic to each Component requires a lot more code to be written, and makes the task of abstracting keyboard control difficult. The KeyboardProcess is responsible for providing a single point of access for keyboard information. Any Components requiring keyboard input to function can simply listen to this top-level Component for events.

Renderer

A Component implementing the IRenderer interface. You usually only have one Renderer per scene. The Renderer process is responsible for placing the output produced by Skins on the screen. In a simple 2D case (Renderer2D), this task boils down to adding a Skin2D to the display list, and placing it at the position defined by the Transform2D Component. However this framework could also be used to describe a 3D rendering pipeline, where a Renderer3D Component renders a Geometry3D with the surface properties defined by a Skin3D at a location defined by a Transform3D Component.

Clone this wiki locally