Crash Course: Let's Make a Game! (Part 3)
by Jon (Updated on 2015-10-17)
Customizing Actors (Part 3 of 5)
We’ve already got some Actor Types in our game, but they aren’t very interesting yet, as without Behaviors, Actor Types can’t do very much.
Creating an “Enemies” Group
Before we jump into customizing our actors, let’s quickly create a Group to categorize our enemies into.
Definition: Groups are used to determine what kinds of Actor Types collide with each other. Groups can also allow you to treat different classes of Actor Types differently. We've got an entire article devoted to Groups and how they affect collisions.
1) Click on the Settings button in the toolbar. The Game Settings window should appear. This is where practically all of your game-wide settings are configured.
2) Switch to the Groups section by clicking the relevant button in the Settings sidebar.
3) Click the green Create New button around the top of the window.
4) Type Enemies in the name field and hit Create
5) Under Collides With, click on Players and Tiles. The buttons you clicked should turn green. This indicates that Enemies can collide with Players and Tiles.
6) Click the OK button in the bottom-right to dismiss the window.
To breathe some life into our main character, Noni, and our enemy, Clown, let’s take a more in-depth look at the Actor Type Editor and add the Behaviors included in the Crash Course Kit.
If you haven’t closed the Noni Actor Type yet, click its tab to select it. Otherwise, navigate to the Dashboard and double-click on Noni from the Actor Types section of the Dashboard.
1) The Appearance page of the Actor Editor appears by default. Skip over to the Properties page by clicking its button at the top of the editor.
2) Check to see that Noni is a member of the Players Group. This will ensure that Stencyl will handle the collisions how we intend.
3) Visit the Physics page by clicking the Physics button at the top of the editor.
4) Under General, toggle the Can Rotate? setting to "No". This will ensure that our actor is always oriented with its feet facing the ground, no matter what.
5) We’re going to move on to the Behaviors section, where the real crux of the customization takes place. Get there by clicking the Behaviors button (right next to the Appearance button). The following screen will appear:
6) Click on the Add Behavior button in the lower-left hand corner.
7) When the dialog appears, double-click the Walking Behavior.
7) We’re taken back to the Behaviors page of Noni. Notice the addition of the Walking Behavior in the list on the left, as well as all of its configurable Attributes in the main pane.
Definition: Attributes are customizable values that make Behaviors reusable and easy to modify. For more about Attributes, see our introductory article about them.
8) Let’s start customizing these Attributes. Some of the Attributes have default values that we can use, like Speed, whereas others we will have to set ourselves.
First, change Move Right Key and Move Left Key to the right and left Controls respectively.
Definition: Controls map physical keyboard keys or gamepad buttons to names you can refer to in your behaviors. If you ever decide to change the actual key, you just have to change it once place. See our Controls article for more information.
9) Then choose the desired animations by clicking on the Choose an Animation button and selecting the animation sequences you want.
That’s it for the first Behavior!
10) Let’s add the rest and customize them in a similar way. To add more Behaviors, click the Add Behavior button at the lower left-hand corner of the editor.
Add and configure the following Behaviors:
Jumping: Make the following modifications to the default values: Choose action1 for Jump Key. Add the Jump Sound so Stencyl will play a sound effect when Noni jumps. Finally, choose Jump Right and Jump Left for the Jump Right and Jump Left animations, respectively.
Stomp on Enemies: Set Stompable Group to Enemies (the group we created at the beginning of this section) and Jump Key to action1.
- Die in Pit and Reload: Nothing to configure here. Just make sure you add it.
Here are all the Behaviors you should have added to Noni:
Clown will be simpler to set up than Noni. Switch over to its tab (or open it from the Dashboard, if need be).
1) Click on the Properties button, as we did with Noni.
2) Go ahead and change Clown’s group to Enemies.
3) All that’s left to do with Clown is to add a single Behavior. Click the Behaviors button and add the Stompable Behavior. Customize the following Attributes as such:
Note: As you may be able to tell, this Behavior makes Clown "stompable" like a Goomba in Super Mario Bros. Clown will "die" when hit from above and play a sound when this happens. If you click the Edit Behavior button, you can peek at the "code" behind this Behavior.
Print Article Edit Article How to Edit an Article