# Actor (of `Prop`)

class `Actor`

  Defined in Actor.sc.

  Actor is the base class for moving objects in your game. It extends `Prop` by providing the following additional capabilities:

  > - A mover property that is responsible for controlling how the Actor moves. This is assigned with setMotion().
  > - An optional Avoider that makes the Actor avoid objects.
  > - Optional “blocks” that indicate areas the Actor can or can’t be.

  Example definition:

      (instance wd40 of Actor
              (properties
                      x 20
                      y 20
                      noun N_ROBOT
                      view 400
                      loop 8
                      signal ignAct
              )
      )

  Example initialization:

      (wd40
              init:
              setMotion: PolyPath 127 128
      )

Subclasses: `Ego`.

## Properties

Inherited from `Prop`:

Property | Description
--- | ---
x | x position. See posn().
y | y position. See posn().
z | z position. See posn().
heading | The angle direction the Actor faces.
noun | The noun for the Actor (for messages).
case | The optional case for the Actor (for messages).
modNum | Module number (for messages)
nsTop | “Now seen” rect. The visual bounds of the Actor.
nsLeft |
nsBottom |
nsRight |
sightAngle |
actions |
onMeCheck | The type of onMe checks that are done.
state |
approachX | The approach spot x.
approachY | The approach spot y.
approachDist | The approach distance.
_approachVerbs | Bitmask indicating which verbs cause the ego to approach.
yStep | The number of pixels moved in the y direction each cycle.
view | The view for Actor.
loop |
cel |
priority |
underBits |
signal |
lsTop | The “last seen” rect...
lsLeft |
lsBottom |
lsRight |
brTop | The “bounds rect” (near the feet of the Actor).
brLeft |
brBottom |
brRight |
scaleSignal |
scaleX | Current x scale.
scaleY | Current y scale.
maxScale | Max scale.
cycleSpeed | How quickly the Actor animation cycles.
script | Arbitrary `Script` object.
cycler | `Cycle` attached to the Actor.
timer |
detailLevel |
scaler | `Scaler` object attached to the Actor.
name |

Defined in Actor:

Property | Description
--- | ---
illegalBits |
xLast |
yLast |
xStep |
origStep |
moveSpeed | How quickly the Actor moves.
blocks |
baseSetter |
mover | The `Motion` object attached to the Actor.
looper | Optional looper code.
viewer |
avoider |
code |

## Methods

`init`(params)

`doit`()

`posn`(theX theY [theZ])

  Sets the position of the Actor.

`setLoop`(loop)

`setLoop`(loopClass [params ...])

`setLoop`(looper [params ...])

  Sets a loop on the Actor, or sets an object that controls which loop is used.

  Parameters: | loop (number) – A loop number. loopClass (class) – A class that has a doit method that controls its client loop (e.g. see `Grooper`). looper (heapPtr) – An instance of a looper class.

`delete`()

`motionCue`()

`checkDetail`(param1)

`setMotion`(theMover sendParams)

  Assigns a mover object to the Actor. The mover is initialized with the Actor and any sendParams that have been provided.

  Parameters: | theMover – A class name, or an instance that inherits from `Motion`. sendParams – Any params that should be forwarded to the mover’s init() method.

  Movers control the Actor’s motion, whether it be via mouse or keyboard input, or some in-game logic.

  Example usage for moving a ball to a particular position, and cueing the caller when it’s done:

      (myBall setMotion: MoveTo 123 100 self)

`setAvoider`(theAvoider sendParams)

`ignoreHorizon`(param1)

`observeControl`(bits)

  Specifies the control colors which the Actor’s movement. This is not used commonly in SCI1.1. Constraining an Actor’s motion is generally done with Polygons instead.

`ignoreControl`(bits)

  Specifies which control colors should no longer block the Actor’s movement.

`observeBlocks`(block)

  Adds a block (an instance which inherits from `Blk`) to the Actor’s list of blocks. These control where an Actor is allowed to go. In SCI1.1, these have generally been replaced by Polygons.

`ignoreBlocks`(block)

  Removes a block from the Actor’s list of blocks.

`isStopped`()

  Returns TRUE if the Actor is not moving, FALSE otherwise.

`isBlocked`()

`inRect`(left top right bottom)

  Returns TRUE if the Actor is inside the specified rectangle, FALSE otherwise.

`onControl`([fUsePoint])

  Provides a bitmask of the control colors on which an Actor is located.

  Parameters: | fUsePoint (boolean) – If TRUE, the Actor’s location is used. If FALSE (or not specified), the Actor’s base rectangle (near its feet) is used.
  Returns: | A bitmask of ctl flags. These should usually be tested with the & operator.

  Example usage:

      (if (& ctlGREEN (gEgo onControl:))
              (Prints {The ego is on Green})
      )

`distanceTo`(obj)

  Parameters: | obj (heapPtr) – An object with x and y properties.
  Returns: | the distance between this Actor and the object.

`cantBeHere`()

  Returns TRUE if the Actor can’t be in its current location.

`setStep`(newX newY [fDontSetOrigStep])

  Sets the pixel increments in which the Actor moves. Bigger increments means the Actor will cover larger distances in each frame.

  Parameters: | newX (number) – The xStep, or -1 if not provided. newY (number) – The yStep, or -1 if not provided. fDontSetOrigStep (boolean) – Optional flag telling us not to set origStep.

`setDirection`(newDirection)

  Sets the direction that the Actor faces.

  Parameters: | newDirection (number) – One of CENTER, UP, UPRIGHT, RIGHT, DOWNRIGHT, DOWN, DOWNLEFT, LEFT or UPLEFT.

`setHeading`(theHeading cueObj cueValues)

  Sets the angle heading of the Actor.

`setSpeed`(newSpeed)

  Sets the speed of the Actor. This controls both the move and cycle speed.