Book Image

Corona SDK HOTSHOT

By : Nevin Flanagan
Book Image

Corona SDK HOTSHOT

By: Nevin Flanagan

Overview of this book

<p>If you've used the Corona Software Development Kit to build your very first new mobile app, you already know how easy it makes developing across all the pieces of this fragmented market. This book upgrades your knowledge of Lua and the Corona API with designs, habits and advanced concepts to speed your development and create more exciting apps.</p> <p>Corona SDK Hotshot will show you how to combine advanced Lua features such as coroutines and metatables with Corona's sophisticated tools, including physics and networking, to develop exactly the game or app you or your customers need, quickly and with an eye towards updating your app with improvements in the future.</p> <p>Corona SDK Hotshot will expand your basic knowledge of Corona with an insight into making the most of its event platform, using physics wisely and easily, and moving on to advanced programming tasks like path-finding.</p> <p>You will focus heavily on how to keep your programs understandable as they become more complicated, by using modules and events to divide it up. You'll practice ways to make AI scripts and map files easily understandable to designers and other collaborators, and use networks like GameCenter to publish progress.</p> <p>The last projects will combine the full range of covered material to illustrate how you can produce sophisticated and exciting apps as a Corona Hotshot!</p>
Table of Contents (18 chapters)
Corona SDK HOTSHOT
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Recognizing kills and recording scores


The world-level interactions between the player, asteroids, and lasers are effectively complete at this point. The remaining tasks are for the game to track those elements that are not part of the world representation; accomplishments and challenges.

Getting on with it

To manage scores, first we'll need to set it when a game begins.

  1. Open game.lua and find the enterScene handler, set the starting value for player score, and dispatch a game event:

      Runtime:addEventListener('touch', self)
      self.Score = 0
      self:dispatchEvent{name = 'Score'; value = self.Score}
      self:Start()
  2. To trigger changes in the score, the game needs to track Destroy events for rocks, which it can receive from the world:

      self:dispatchEvent{name = 'Score'; value = self.Score}
      self.World:addEventListener('Destroy', self)
      self:Start()
  3. Before moving on, keep registration balanced by removing the listener in the exitScene handler:

    function scene:exitScene( event )
      Runtime:removeEventListener...