What are Actors?
This article introduces you to the key concepts behind actors, without getting into much detail. Because Actor concepts are intertwined, it's useful to get a little exposure to each before delving into full detail.
What are Actors?
Actor Types and Instances
What are Actors?
Actors represent the living, interactive part of a game. Actors are the players, enemies, projectiles, vehicles, inteface elements and anything in a game that "lives."
[Insert Image of several different actors]
Every actor can be broken up into a few common elements.
Appearance - How the actor looks or appears in-game.
Behavior - How the actor behaves or acts.
Physics - How the actor interacts with the world when it collides with it. This also determines what shape(s) the actor takes on, whether it's a box, a circle or something else.
Appearance dictates how an Actor looks. In the 2D games we build, this means Animations.
Animations are a collection of frames that are played out in sequence and usually loop, to form a fluid, living visual representation of the actor.
Actors need not be bound to a single animation. They can switch between different states, each which are associated with their own Animation and collision bounds.
More concretely, consider the hero character in a platformer such as Mario. This character will have states for standing, walking, running and jumping.
Note: Coming from Scratch? Animation States are called costumes over there.
Further Reading: We go into much further detail about Animations and States later in this chapter.
Behaviors tell an actor what to do and how to react. They provide specific logic which allows the actor to perform unique tasks like run, jump, walk, fire weapon and more.
Behaviors are unique in that they are reusable and configurable.
Reusable: They can be attached to other actors. (Example: Attach a Fire spell behavior to other actors)
Configurable: You can configure their Attributes (properties) (Example: Set the walking speed)
You may notice an "Events" page when opening up the Actor Editor. This page lets you attach Events directly to an actor, without requiring a full behavior.
This is useful for adding logic that's specific to the actor and great for rapid prototyping.
Note: Events are new to Stencyl 2.0. In the past, we found that our users would create Behaviors just for one particular Actor Type, which cluttered up their projects.
Further Reading: We don't cover the Behaviors or Events pages in Chapter 3, since you got exposed to plenty of that already in Chapter 2. For a refresher, read Chapter 2's introduction.
In many games, Actors collide with other Actors, In our engine, our Actors obey the laws of physics and act much like real-world objects.
In order to make this all happen, the Actors need to assume a physical form, whether it's a box, a circle, a polygon or some combination of those.
These physical forms are known as Collision Bounds, and they are tied directly to Animation States. Intuitively, this makes sense. If your character stands, he takes on one shape. If he's "ducking" on the ground, his shape will be shorter.
Sensors allow collisions to occur without generating a physical reaction. This is useful when you don't want a certain Actor to "push" other actors away but do want that collision to happen.
For example, slashing a sword or being hit by a fireball shouldn't always knock you back, but it should definitely hurt.
Groups let you filter collisions, so that only certain classes of Actors collide with each other.
To take a real-life example, consider the concept of "friendly fire" - sometimes, you don't want your enemy's bullets to kill other enemies. Groups let you prevent this from happening.
As mentioned earlier, Actors obey the laws of physics. The Physics page lets you tweak an actor's physical attributes that don't pertain to its collision bounds.
Here are just some of the properties you can tweak.
Whether an actor moves, rotates or obeys gravity.
Further Reading: We cover Collisions & Groups in a separate article, and Physical Properties in its own article too.
Actor Types vs. Instances
Two terms you may see thrown around are Actor Types and Actor Instances. More confusingly, we may abbreviate both to simply "Actor", with no indication, outside of context, which of the two we're talking about.
The difference is this: Actor Types are like templates or prototypes, while instances are the actual "Actors" that exist inside a scene.
Consider a game like Super Mario Bros. A Goomba is a common enemy in this game. We expect Goombas to look like this:
And we expect them to act in the same way, namely to walk in one direction until they hit a wall, then reverse direction.
But every instance of Goomba exists at a different location on the scene. When you step on one, it dies. These are each separate instances of Goomba.
This, in a gist is the distinction between an Actor Type and Actor Instance.
Programmers' Note: Types are akin to Classes, while Instances are akin to Objects.
Actors are the things that make a game come to life. In simple terms, they are the "objects" or "props"
Actors can take on different Animation States, each with their own Animation and Collision Bounds.
You can control how an Actor acts by attaching Behaviors or Events.
Actors obey the laws of physics. You can tweak an Actor's physical properties such as whether it can move, its mass and friction.
Last Updated: 2013-01-29 by Jon
27522 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game,
please ask a question on the forums. Thanks!
Sign In to Comment