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

Coin collection


Let's start working on the coin collection code. To do so, perform the following steps:

  1. In the Dashboard, under Actor Behaviors, open up the Player Handler.

  2. Click on Attributes toward the bottom-right of the screen, as shown in the following screenshot:

  3. Click on Add Attribute to create our new Score attribute, as shown in the following screenshot:

  4. In the ensuing window, set the Name to Score.

  5. Set Type to Number.

  6. Check Hidden?.

  7. Click on OK to create the attribute.

Now that we've created our Score attribute, we can start writing the code to detect the collisions with Coins, and increment this value accordingly. To accomplish this, perform the following steps:

  1. Navigate to Add Event | Collisions | Actor of Type, as shown in the following screenshot:

  2. Click on the Actor drop-down menu, and select Self, as shown in the following screenshot:

  3. Click on the Actor Type drop-down menu, and select Choose Actor Type.

  4. A list of all the available Actor Types will pop up. Select Coin and click on OK.

  5. The...