If he's "ducking" on the ground, his shape will be shorter. If your character stands, he takes on one shape. These physical forms are known as Collision Bounds, and they are tied directly to Animation States. 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. In our engine, our Actors obey the laws of physics and act much like real-world objects. In many games, Actors collide with other Actors. For a refresher, read Chapter 2's introduction. This is useful for adding logic that's specific to the actor and is also great for rapidly prototyping ideas.įurther 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.
#Stencyl create actor full
This page lets you attach Events directly to an actor, without requiring a full behavior. You may notice an "Events" page when opening up the Actor Editor. For example, if you attached a Walking behavior to an actor, you could customize its walking speed. You can configure their Attributes (properties).
#Stencyl create actor code
Reuse is good because it saves you effort and prevents bugs stemming from duplicate code (that you are likely to edit in the future). They can be attached to other actors, thereby letting you reuse the same behavior for multiple actors. They provide specific logic which allows the actor to perform unique tasks like run, jump, walk, fire weapon and more.īehaviors are unique in that they are reusable and configurable.
#Stencyl create actor how to
Behaviorsīehaviors tell an actor what to do and how to react. This character will have states for standing, walking, running and jumping.Ĭoming from Scratch? Animation States are equivalent to costumes.
They can switch between different states, each which are associated with their own Animation and collision bounds.Ĭonsider the hero or "player" character in a platformer such as Mario. In the 2D games we build, we call these animations.Īnimations are a collection of frames that are played out in sequence and usually loop, to form a fluid, living visual representation of the actor.Īctors need not be bound to a single animation. This also determines what shape(s) the actor takes on, whether it's a box, a circle or something else.Īppearance dictates how an Actor looks. Physics - How the actor interacts with the world when it collides with it.Behavior - How the actor behaves or acts.Appearance - How the actor looks or appears in-game.Actors are the players, enemies, projectiles, vehicles, inteface elements and anything in a game that "lives."Įvery actor can be broken up into a few common elements. ContentsĪctors are the living, interactive parts of a game. Because Actor concepts are intertwined, it's useful to get a little exposure to each before delving into full detail. We now need to ensure our Bullet Actors are destroyed when they collide with the Enemy Ships and when they leave the screen.This article introduces you to the key concepts behind actors. Test the game again, and press Action 1 to shoot your bullets (should be Z by default). Remember, that “up” on a computer screen is in the negative y direction. Set xDir to 0 (we only want the Ship to shoot bullets toward the Enemy Ships, which is up, not horizontally) and yDir to -1.
Step 77: From here, we set the direction and force the Bullet Actor will launch at in the push block. Then switch the to in the second block, as shown. Alternatively, cClick on each dropdown (for x and y) to choose the x of self block from the Actor category in the Block Picker. For the x and y values, set them to x of self and y of self, which is the current position of the Ship on screen. Step 76: Next, we need to set where the Bullet is created and the direction it should travel in. Snap them together into the Event block, as shown. Select the Bullet Actor Type by clicking on the dropdown on the create Actor Type block, and in the blue push block, change the field to and to. The first is under Scene -> Actors in the Palette. Step 75: Now we need to grab two blocks, one that creates our Bullet Actor and another that sends it on its way. Step 74: On the block that appears, set the control dropdown to action 1, as shown. Tip: To make sure your bullets fire properly, make sure you remembered to set their Actor Type in the Physics tab to Normal.