Username or E-mail
Password (Forgot?)
New? Sign Up
Join or Sign In
Forums Stencylpedia Stencyl TV Translations Go Pro - Plans & Pricing Download Stencyl


Switch to Book Layout

1: Getting Started

  • Getting Started
  • Crash Course
  • Crash Course 2
  • StencylForge

2: Building Logic

  • What is a Behavior?
  • Creating a Behavior
  • Attributes
  • Game Attributes
  • Attribute Types
  • Events
  • Our Behaviors

3: Actors

  • What are Actors?
  • Animations
  • Motion & Forces
  • Physics
  • Controls
  • Collisions & Groups
  • Killing vs. Recycling
  • Tweening
  • Effects
  • Chapter 3 Challenge

4: Scenes

  • Scene Basics
  • The Camera
  • Tilesets
  • Regions
  • Drawing Text & HUDs
  • Changing Scenes
  • Music, Sounds & Channels
  • Backgrounds
  • Customizing Actors
  • Chapter 4 Challenge

5: Game Mechanics

  • Saving
  • Pausing
  • 3rd Party Services
  • Web Requests

6: Advanced Topics

  • Get/Set Attributes
  • Custom Events
  • Blending Modes
  • Lists
  • Custom Blocks
  • Continuous Collisions

7: Testing & Tuning

  • Testing Games
  • Optimizing Performance 1
  • Optimizing Performance 2

8: The Last 10%

  • Flash Publishing
  • Standalone Apps
  • iOS App Store
  • Chrome Store
  • Making Money

M1: Mobile - Intro

  • Getting Started
  • Testing on your Device
  • Flash -> iOS Guide

M2: Mobile - Basics

  • Atlases
  • Drawing Text
  • Retina Display
  • Accelerometer
  • Joystick
  • Universal Games

M3: Mobile - Services

  • iAds
  • Game Center
  • In-App Purchases

M4: Mobile - Publishing

  • Debugging
  • Publishing to the App Store
  • Optimizing Performance
  • Promoting your Game

A: Troubleshooting

  • Showstoppers
  • General FAQ
  • iOS FAQ
  • The 90% Memory Warning
  • Recovering Broken Games
  • Can't Export to SWF
  • Reloading Documents
  • Generating Logs
  • Flash Security Settings
  • How to Report Bugs

B: How-To Guides

  • Importing Assets
  • Scene Designer
  • Code Mode
  • Font Editor
  • Pencyl (Image Editor)
  • Tile Editor (Shapes)
  • Game Cleaner

C: Reference

  • Glossary
  • Block Reference
  • Useful Shortcuts
  • Stencyl API

D: Resources

  • Stencyl TV
  • Abigayl's Guides
  • Giving Critiques
  • Creating Extensions
  • Translating Stencyl
  • Credits

3.0 Drafts (In Progress)

  • What's New in Stencyl 3.0?
  • Setup (Android)
  • Setup (Desktop)
  • Setup (iOS) - Concepts
  • Setup (iOS) - Mac
  • Setup (iOS) - Windows
  • Testing iOS on Windows
  • iOS Troubleshooter

  • Mobile App Scaling
  • Full Screen Mode
  • Simple Physics
  • Backgrounding an App

  • iOS App Store
  • Mac App Store
  • Windows Store
  • Google Play
  • HTML5

  • Android Ads
  • Android Purchases (WIP)
  • 4" Form Factor (iPhone 5)
  • Mobile Input
  • Mobile Features

  • Extending the Engine
  • iOS / Android Extensions
  • Developing the Official Extensions
  • Developing the Engine

  • iAds (Revised)
  • Game Center (Revised)
  • iOS Purchases (Revised)
  • Atlases (Revised)
  • Drawing Text (Revised)
  • Joystick (Revised)
  • Accelerometer (Revised)
  • Sounds (Revised, WIP)
  • Debugging (Revised, WIP)
  • iOS Performance (Revised)
Level: Beginner

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.

 

Contents

  • What are Actors?
  • Appearance
  • Behaviors
  • Collisions (Physics)
  • 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

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

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)


Events

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.

 

Collisions (Physics)

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

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

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.

 

Physical Properties

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.
  • Mass
  • Friction
  • Bounciness
  • Damping

 

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.

 

Example: Goombas

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.

 

Summary

  • 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

18742 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!
2 Comments
Takarashi282
Typo under "Collisions (Physics)": 'If he's "ducking" on the ground, his shape will llikely be shorter'
*likely
These are wonderful examples by the way.

-1 8 months, 1 week ago
snortch
nice use of examples here Jon.
1 9 months, 2 weeks ago



Commenting Guidelines

Sign In to Comment

Make Games

  • What is Stencyl?
  • Roadmap
  • Pricing

Play

  • Arcade
  • Showcase

Community

  • Forums
  • Chat
  • Translations

Help

  • Stencylpedia
  • Stencyl TV

About Us

  • Blog
  • Contact Us
  • Press
  • Privacy
Follow Stencyl on Twitter



© 2013 Stencyl, LLC.