Switch to Book Layout1: Getting Started2: Building Logic
3: Actors
4: Scenes
5: Game Mechanics6: Advanced Topics7: Testing & Tuning8: The Last 10%M1: Mobile - IntroM2: Mobile - BasicsM3: Mobile - ServicesM4: Mobile - PublishingA: Troubleshooting
B: How-To Guides
C: ReferenceD: Resources3.0 Drafts (In Progress)
|
||
|
Level: Beginner
Working with BehaviorsTaking advantage of existing Behaviors is a great way to get a game up and running quickly. Eventually, however, you’ll come across a Behavior that you want to tweak, or you’ll want to implement functionality for which no Behavior exists at all. For these cases, you’ll need to dive into Stencyl’s Design Mode.
Note: This article is mainly a "how-to" article that familiarizes you with our signature block-snapping interface. If you're searching for an article on how to "think" and tackle problems, that will be covered in a future article.
Contents
Creating a BehaviorLet’s continue with the vertical shoot ‘em up game we were creating in our last article. We’ll see how we can create a simple laser-shooting Behavior from scratch. 1) Go ahead and click the Create New button in the toolbar, since we’ll be creating a new resource.
2) Choose the Behavior resource type, enter a name (such as "Fire Laser"), and click Create.
Note: You might be curious about those other modes... Both are for advanced users.
Code Mode lets you create Behaviors by writing straight-up code. Freeform Mode lets you add arbitrary code, entirely outside our Behavior system.
Overview of Design ModeAfter clicking Create, Design Mode appears. Let’s take a moment to get acquainted with the interface.
The main interface is divided into three parts – the event pane, the workspace, and the palette.
Adding an Event
Reminder: 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.
Let’s go ahead and create an event that will let our ship fire a laser. 1) Click Add Event, and select Keyboard from the Input menu.
2) An Event wrapper block pops up. When the Event is triggered, any blocks placed inside the wrapper block will be executed.
3) Notice the two dropdown boxes. if you click on one, you’ll notice you can select from multiple options. Let’s first choose a control for firing the laser.
Note: Controls are map physical keys on your keyboard to human-friendly names. If you flip to the Controls page under the game's Dashboard, you can see what physical key Fire1 maps to.
Defining the Event ResponseNow we need to define the actions that should occur whenever the Fire1 control is pressed. These actions are called the Event Response. Specifically, we need to first create a laser Actor Type and then set its velocity.
Tip: The Search Box
We can use the search box inside the palette to help find the blocks we need. Just type in a word that appears as part of a block’s text, and press Enter/Return. ![]()
Part 1 - Finding Blocks1) Use the search box inside the palette, to find the following blocks:
2) While holding the Alt key, drag the x of [Self] block to a new location to create a copy of the block.
Tip: Holding Alt and dragging a block will automatically clone it.
Part 2 - Fill in the FieldsThe white rectangles inside these blocks are called fields. You can change a field’s value in several ways:
Part 3 - Fill out the Event4) Use your drag-and-drop, point-and-click, and typing skills to create the following logic snippet, and “snap” it inside the Event wrapper block, like so:
In words, we’re creating a bullet Actor 20 units above the player’s ship and are setting its vertical speed to -20 (meaning 20 in the “up” direction). 5) If you want to test the Behavior out, attach it to your ship like we did in the previous article, or use the Attach to Actor Type button.
A RecapThat's all there is to building a simple Behavior. Assuming you know what kind of logic you're building, it's a matter of gathering blocks via whatever method you're comforatable with, filling in their blanks, and piecing them together into a functional stack that represents the functionality you desire.
Summary
Challenge: A New WeaponAdd a second event to the Behavior that causes the ship to fire a different weapon when a “special attack” control is pressed.
Last Updated: 2012-04-15 by Joe
26618 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!
11 Comments
zencylmaster
Just a direct link to the player on Vimeo... http://player.vimeo.com/video/49919 132 Done for now. Thanks to authors of earlier comments for pointing me in the right direction! -Zencylmaster 0 8 months, 3 days ago
zencylmaster
Embed Code for Vimeo showing the workaround... <iframe src="http://player.vimeo.com/v ideo/49919132" width="500" height="340" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></ifr ame> Enjoy. -Zencylmaster 0 8 months, 3 days ago
zencylmaster
Hello. Found a workaround for adding an event for the Shoot em Up Game which works for Stencyl(Works) v. 1.3.4. Posted it to http://phosphorescentcave.ca/?page_ id=228 0 8 months, 3 days ago
Haddadmj
@FrostBite if you want to solve it you must read the article in the note section in part 3 after step 4 0 9 months, 3 days ago
Zkichiro
@Frostbite, set the bullets collision group to enemies, you might have set it to collide with your player 0 9 months, 2 weeks ago
FrostBite
i´ve solved it at the physics tab and settting cannot move. have i done this the right way??? 0 11 months, 4 weeks ago
FrostBite
Everything works fine, but when i fire the bullet my ship goes down 0 11 months, 4 weeks ago
mguido730
To the three of you, you all need stencyl 2.0 for the event pane to show up. Events are a whole new system they introduced in 2.0. It's much easier to use than the old system, so i recommend downloading 2.0 from the home page. 0 1 year, 1 month ago
Gamedragon
I don't have a event pane either but if you go into custom and pick create custom block I think it does the same thing. 0 1 year, 1 month ago
rwrspicer
I'm having the same issue where the event pane doesn't show up (running version 1.4.1). Is there a different way to create new events in this version? 0 1 year, 1 month ago |




























