Time for action – attaching another behavior to the actor

The game file to import and load for this session is 5961_02_09.stencyl.

We can easily prevent actors from leaving a scene by attaching another behavior, so our next task is to do just that!

  1. Ensure that the Stencyl Book Monkey tab is active.
  2. If the Stencyl Book Monkey tab isn't currently open, go to the Dashboard, click on Actor Types under the RESOURCES heading, and double-click on the thumbnail image for the monkey.
  3. Click on the Behaviors button at the upper-center of the screen.
  4. Click on the + Add Behavior button at the very lower-left corner of the screen.
  5. In the left-hand side panel of the Choose a Behavior dialog box, click on the Motion option that appears under the FROM YOUR LIBRARY heading.
  6. Find the Cannot Exit Scene behavior in the main panel, and double-click it. Be careful not to select the similarly named Cannot Exit Screen behavior—it doesn't do exactly what we need!
  7. Read the information on the behavior screen that is now being displayed:
    Time for action – attaching another behavior to the actor
  8. Click the Test Game icon to see if the monkey can still leave at the edges of the scene, then close the Flash Player window.

What just happened?

We've attached a second behavior to the monkey actor, and this additional behavior is designed to prevent the actor from leaving the scene. Hopefully, we could see that the behavior did its job when we tested the game!

Unlike the Jump and Run Movement behavior, which had some information that needed to be configured, the Cannot Exit Scene behavior does not have any attributes that can be changed, so we were able to jump straight into testing the game, as soon as the behavior had been attached to the actor.

Increasing the width of the gameplay area

Currently, our monkey only has a very small area in which to play, as he is restricted to moving within the confines of our game window which is quite small—640 pixels wide and 480 pixels high. This is a common screen size for Flash games, which is why it is the default size for Stencyl games.

It might be possible to create an interesting jungle scene in such a small space but, we can make the game more interesting for our players, if we make the gameplay area much wider, so let's change the settings for the Jungle scene to make it three times as wide.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.135.88