1: Getting Started
2: Building Logic
5: Game Mechanics
6: Advanced Topics
7: Testing & Tuning
8: The Last 10%
M1: Mobile - Intro
M2: Mobile - Basics
M3: Mobile - Services
M4: Mobile - Publishing
B: How-To Guides
3.0 Drafts (In Progress)
Introduction to Behaviors
As a game creator, it’s not enough to add a bunch of resources to a Scene and call it a day; you have to define gameplay that will engage your players and make your game interactive.
To do this, you’ll use Stencyl’s Behavior Designer to build self-contained snippets of logic called Behaviors and attach them to your Actor Types and Scenes.
Note: In response to our readers, we would like to clarify that there is no associated demo/source with this article. Our apologies for the confusion!
Behaviors are reusable, configurable “abilities” that you attach to Actor Types or Scenes. Together, they make up the “brains” of a game, handling all interactions that occur in the world.
Say we’re making a vertical shoot 'em up where the player controls a ship that can fire lasers.
Let’s attach a Behavior that will allow the player to fire a laser when the spacebar button is pressed.
To attach a Behavior, perform the following steps:
Behaviors can be reused and configured individually for different Actor Types or Scenes. For example, if you attach a Walking behavior to an Actor Type, you'd like to be able to configure its walking speed.
The customization occurs on the Behaviors tab, by modifying parameters called Attributes.
Let’s configure the Fire Laser Behavior for our ship Actor. First, select the Behavior you want to customize, and then fill in values for each field that’s displayed.
In this ship example, we...
Now that the Fire Laser Behavior has now been attached and configured, let's see this in action.
The Demo Game
(Press spacebar to fire the laser)
Actor Type vs. Scene Behaviors
The Behavior we created was an Actor Type Behavior and thus is available to be attached to any Actor Type (e.g., the ship).
We also have the ability to create Scene Behaviors that can get attached to any Scene. An example of this would be a "spawn" Behavior that periodically creates new enemies at the top of the screen.
Let’s take a look at a typical Behavior.
On the left you see a list of Events that can happen, and on the right, you see the response to the currently selected event. You can click on other events to display their associated responses.
We'll talk much more about what's happening on the right side later in this chapter.
Events are the building blocks of Behaviors. In short, they’re things that happen in your game that can trigger some kind of action, or response.
Returning to our vertical shoot ‘em up example, remember that when the player presses the spacebar, the player’s ship fires a laser.
In this case, hitting the spacebar is the event, and firing the laser is the response. The event and response are related by cause and effect.
Last Updated: 2013-01-29 by Jon
40974 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!