Book Image

Stencyl Essentials

By : Richard Sneyd
Book Image

Stencyl Essentials

By: Richard Sneyd

Overview of this book

Table of Contents (20 chapters)
Stencyl Essentials
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Programming the button


Great! Now that we have created and configured the Play Game Button, we must write an Actor Behavior that will cause it to behave like a button by reacting to the mouse's events. To do so, perform the following steps:

  1. Go to the Dashboard tab, select Actor Behaviors, and click on Create New.

  2. In the ensuing window, set Name to Play Button Handler, and click on Create.

  3. Navigate to Add Event | Input | On Actor, as shown in the following screenshot:

  4. Switch the condition from enters to is pressed on, as shown in the following screenshot:

  5. In the blocks palette, navigate to Scene | Game Flow | Transitions, drag out and add a switch to Scene and Crossfade block, as shown in the following screenshot:

  6. Click on the Scene field, and select Choose Scene, as shown in the following screenshot:

  7. A window will appear, displaying all of the available scenes. Select Level 1, and click on OK.

  8. Set for secs to 1, as shown in the following screenshot:

  9. Click on Attach to Actor Type, and select Play...