Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 5.x 2D Game Development Blueprints

You're reading from   Unity 5.x 2D Game Development Blueprints Explore the features of Unity 5 for 2D game development by building three amazing game projects

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781784393106
Length 252 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Francesco Sapio Francesco Sapio
Author Profile Icon Francesco Sapio
Francesco Sapio
Abdelrahman Elsayegh Abdelrahman Elsayegh
Author Profile Icon Abdelrahman Elsayegh
Abdelrahman Elsayegh
Arrow right icon
View More author details
Toc

Implementing a money system


The player will earn money by killing enemies, and he is able to spend it by buying new towers to defend his fortress. By doing this, we need a game element that is able to handle a money system, in which the amount of money can increase and decrease according to the player's actions. This section will teach us how to create a money system and integrate it in the UI.

Creating and placing the money counter

As we previously did in the Lives Counter, we need to create the UI structure. So, let's create a new UI Image by right-clicking on the Hierarchy panel and then UI/Image. Rename it MoneyCounter and assign to the Source Image the currency_square image of our package. Also, we should press the Set Native Size button and then scale it down. As before, make it a tiny bit transparent by setting the alpha channel of the color variable to 232. Finally, place it just under the LivesCounter, as in the following image:

Similarly to the LivesCounter, let's create a uiText...

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