Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Stencyl Essentials

You're reading from   Stencyl Essentials Build beautiful, unique, cross-platform games rapidly with the free Stencyl 2D game engine and toolset

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784399450
Length 206 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Richard Sneyd Richard Sneyd
Author Profile Icon Richard Sneyd
Richard Sneyd
Arrow right icon
View More author details
Toc

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:
    Coin collection
  3. Click on Add Attribute to create our new Score attribute, as shown in the following screenshot:
    Coin collection
  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:
    Coin collection
  2. Click on the Actor drop-down menu, and select Self, as shown in the following screenshot:
    Coin collection
  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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image