Game Development Reference
In-Depth Information
CGPoint center
: The property
center
defines the location of the center of the
Actor in game coordinates.
float rotation
: The
rotation
property indicates the rotation of the Actor in
radians.
float radius
: The
radius
of the Actor describes how big it is. Together,
center
and
radius
describe the area of the game occupied by the
Actor
.
NSMutableArray* behaviors
: The
behaviors
property is a collection of
Behavior
objects. A
Behavior
object describes some sort of aspect of an Actor. It might
describe how it moves or when it is removed from the game. Each
Behavior
in
the
behaviors
array will be applied to the
Actor
on each step of the game.
BOOL needsViewUpdated
: Throughout a step of the game, an
Actor
may undergo
changes that require its
UIView
to be updated. These might include advancing
the image that should represent it or a change in state. This flag informs
the
GameController
that work is required to synchronize the
Actor
with its
representation.
NSObject
<
Representation
>
representation
: Each
Actor
in the game requires
an object conforming to
Representation
to describe how to create a
UIView
to
represent it in the game.
Representations
are discussed in the next section.
int variant
: It is common to have
Actors
in a game that differ only slightly.
Perhaps they are a different color or have a slightly different behavior. Since
this is a common requirement, the property
variant
provides a simple way of
distinguishing
Actors
of the same class.
int state
: The property
state
is used to describe the state of an
Actor
.
This state can be anything, and is up to the subclass to define exactly
what this indicates. The property
state
and
variant
work with the class
ImageRepresentation
to figure out which image should be used for an
Actor
.
float alpha
: The property
alpha
describes how opaque an
Actor
is. An
Actor
with an
alpha
of 0.0 is fully transparent, while an
alpha
value of 1.0 is fully
opaque. Transparent regions in an
Actor's
representation are unaffected.
BOOL animationPaused
: The property
animationPaused
is used to pause any
animation that is being applied to the Actor. It is up to the implementation of the
animation to honor this value.
ImageRepresentation
will not update the image, in
a sequence of images, used to represent an
Actor
if this property is true.
In addition to the properties that define an Actor, there are a handful of tasks that come with the
class Actor. These are the following:
-(id)initAt:(CGPoint)aPoint WithRadius:(float)aRadius AndRepresentation:
(NSObject<Representation>*)aRepresentation
: This task is the designated
constructor for the class
Actor
. It requires that each Ac
t
or has a center, a radius,
and a representation. All subclasses of
Actor
should be sure that this task gets
called when the
Actor
is created.