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
Gideros Mobile Game Development

You're reading from   Gideros Mobile Game Development With Gideros you can develop games for both iOS and Android faster and more simply. This book shows you how with a real-life project you undertake yourself. All that's required is a little familiarity with Lua.

Arrow left icon
Product type Paperback
Published in Nov 2013
Publisher Packt
ISBN-13 9781849696708
Length 154 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Arturs Sosins Arturs Sosins
Author Profile Icon Arturs Sosins
Arturs Sosins
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Gideros Mobile Game Development
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Setting Up the Environment FREE CHAPTER 2. Managing Scenes and Gideros OOP 3. Implementing Game Logic 4. Polishing the Game Index

Adding high scores


Implementing high scores is a must for almost every game to make players compete with each other or to make players replay levels to improve their result. So let's modify our GameManager class to also manage score for each level.

Inside our GameManager class createLevel method, we already stored default score and time values, so now we only need methods to set and retrieve them.

First, we will create a method to set the score, which would simply take pack and level number and the user score as the parameters, and return true to indicate that the user has beat a high score or false if the user'sscore is lower than the highest score.

So, as done previously for almost each GameManager method, at first we try to load the pack and create the level information if we need. Then we check if the user's high score is higher than the saved one; and if it is, we save the new score and time when it was achieved. Then we return true, else we simply return false.

function GameManager:setScore...
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