Create an Actor
Everything that can be given to the Actor constructor, other than data,
which has its own rules (see the constructor)
What the actor looks like: one appearance component, or an array of them, drawn in order. An empty array is an error.
Optionalbehaviors?: Behavior | Behavior[]What the actor does when it touches other actors: one behavior, or an array
of them. If omitted, the actor has a PassiveBehavior, so it doesn't
collide with anything
Optionalgestures?: GestureHandlersFunctions to run when the player touches, pans, swipes, or hovers over the actor
Optionalmovement?: MovementComponentHow the actor moves. If omitted, the actor only moves when physics moves it
OptionalonDisappear?: (a: Actor) => voidCode to run when the actor disappears
The physical body (BoxBody, CircleBody, or PolygonBody). It also
decides which scene the actor lives in. Required, because every actor needs
a place in the world.
Optionalsounds?: SoundEffectComponentThe sounds to play for this actor, such as when it disappears
Data to attach as actor.data. It is required
if D is anything other than unknown, so
that actor.data always has the type it claims
ReadonlyappearanceThe visual representation of this Actor within the game
ReadonlybehaviorsThe behaviors that this Actor exhibits within the game. An Actor can carry more than one -- e.g. a Hero-like actor typically has a PlayerControlBehavior, a JumpBehavior, and a HealthBehavior all at once.
ReadonlydataData that is specific to this actor, of whatever type was given at construction time. It is strongly typed.
A set of functions describing how the Actor should respond to gestures.
ReadonlyidA unique, creation-order id. Used to deterministically break ties when two Actors' Behaviors both might react to the same contact: whichever Actor has the lower id is given the first chance to react.
ReadonlyonCode to run when the actor disappears
ReadonlyprerenderTasks to run immediately before every render of this Actor, in the order that they were added. Each task receives the time since the last render, and the Actor. They are useful for any rule that depends on something that changes every frame, like "am I behind the camera?".
ReadonlyrigidA physical context for the Actor. This is necessary if the Actor will move, participate in collisions, or receive gesture inputs.
The scene where the Actor exists
ReadonlysoundsThe packet of information describing the audio aspects of this Actor
ReadonlystateThe current state of this Actor
Is this Actor visible and able to interact with the world?
Set whether this Actor is visible and able to interact with the world
The rules for how this Actor should move
The rules for how this Actor should move. Reassigning this away from a
TiltMovement unregisters it from stage.tilt first, so a stale
registration doesn't keep receiving tilt input for the rest of the level
(see TiltService.removeTiltActor).
Actor is the main entity of the game. Pretty much everything on the stage is an actor.
An actor can carry data of type
Din itsdatafield.Dwill be inferred by thedataargument provided to the Actor constructor. If you omit it,datawill have typeunknown.