CAAT.Actor

CAAT.Actor is the simplest object instance that CAAT is able to manage. Every on-screen element is an Actor. In fact, the Director and the Scene objects are a kind of CAAT.Actor instance as well.

This object class contains default functionality for:

  1. Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
  2. Set affine transforms (rotation, scale and translation)
  3. Define life cycle.
  4. Manage alpha transparency.
  5. Manage and keep track of applied Behaviors.
  6. Compose transformations. A container Actor will transform its children before they apply their own transformation.
  7. Enable clipping.
  8. The API is developed to allow method chaining when possible.
  9. Handle input (either mouse events, touch, keys and accelerometer)
  10. etc.

This class is the superclass for other Actors, so it must be specialized to perform concrete operations. There some out-of-the-box Actors already available in CAAT:

  • ImageActor
  • SpriteActor
  • TextActor
  • ShapeActor
  • InterpolatorActor
  • PathActor
  • ...

but as you'll see, developing a new breed of Actors will be just a few lines of code.

One important fact about Actors is the coordinate system. An Actor will always report local coordinates despite the transformation applied to it. In example, an Actor can be scaled twice widely, and rotated 45 degrees, and on mouseMove the received event will report local Actor coordinates as if the actor itself weren't transformed.

An Actor by itself won't display on screen. The correct hierarchy to be defined is as follows:

  • Create a Director
  • Create a Scene
  • Add at least one Scene to the Director
  • Add Actor instances to the Scene