Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
Learning Construct 2

You're reading from   Learning Construct 2 Design and create your own engaging, extensible, and addictive game using Construct 2

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781784397678
Length 234 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Aryadi Subagio Aryadi Subagio
Author Profile Icon Aryadi Subagio
Aryadi Subagio
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Adding collectibles

Collectibles are coins or other objects that the players can collect in the game. These collectibles often add something like scores or game coins. In our game, the collectibles will also be randomized. First, create a new star game object with a sprite from starGold in the Tappy Plane folder and put it in the Collectibles layer. Give it a Bullet behavior and put it outside the screen.

We will create new collectibles every few seconds instead of making them every time the game creates a ground object, like the rock obstacles object. To make collectibles, write the following code:

Adding collectibles

We also want to show what these collectibles collect. So, let's create a new text object; name it scores and put it in the HUD layer. Put it in the upper-left part of the screen; this is where HUDs usually are, although they can be in a variety of places. Now, when the player collects the collectibles, we want the collectibles to be destroyed and then add the score. So, create a global variable...

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