O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Corona SDK HOTSHOT

Book Description

A deep, solid guide with 10 projects specifically designed to expand the fundamentals of exciting mobile development platform

  • Ten fully developed code projects that build on previous projects and present new techniques.

  • Freely reusable art and sound files included with every project help you jumpstart your own development.

  • Numerous advanced techniques to make the most out of Corona's features and the Lua programming language.

In Detail

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.

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.

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.

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.

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!

Table of Contents

  1. Corona SDK HOTSHOT
    1. Table of Contents
    2. Corona SDK HOTSHOT
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Bat Swat – An Introduction to App Event Cycles
      1. What do we build?
        1. What does it do?
        2. How is it excellent?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Describing the game
        1. Getting on with it
        2. What did we do?
        3. What else do I need to know?
      3. Defining the event flow
        1. Getting on with it
        2. What did we do?
        3. What else do I need to know?
      4. Creating the objects
        1. Getting ready
        2. Getting on with it
          1. Loading art assets and libraries
          2. Loading the world
          3. Linking the game with the world
          4. Loading a new game into the display
          5. Preparing the game challenges
          6. Responding to world changes
          7. Monitoring game progress
          8. Concluding the game
          9. Understanding your libraries
        3. What did we do?
      5. Creating the interface
        1. Getting on with it
          1. Adding visible information
          2. Updating an information display
          3. Linking the interface to the game
          4. Triggering a game event from a world event
        2. What did we do?
        3. What else do I need to know?
      6. Adding the Shell
        1. Getting ready
        2. Getting on with it
          1. Creating a staging zone for high scores
          2. Linking the shell into the play cycle
        3. What did we do?
        4. What else do we need to know?
      7. Tracking high scores
        1. Getting ready
        2. Getting on with it
          1. Linking to the database file
          2. Initializing the database
          3. Cleaning up old scores
          4. Considering possible new high scores
          5. Saving new high scores
          6. Recovering old high scores
          7. Communicating scores between modules
          8. Reviewing new scores
          9. Displaying the score history
        3. What did we do?
      8. Adding finishing touches
        1. Getting ready
        2. Getting on with it
          1. Changing the creatures' motion
          2. Animating on a custom curve
          3. Adding visual interest to the high scores
          4. Parameterizing the game length
        3. What did we do?
      9. Game over – wrapping it up
      10. Can you take the HEAT? The Hotshot Challenge
    10. 2. SuperCargo – Using Events to Track Game Progress
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Describing the game
        1. Getting on with it
          1. Core mechanic
          2. Interface summary
          3. Persistence requirement
          4. Data format
          5. Additional data requirements
          6. Preliminary module design
        2. What did we do?
      3. Loading a level from a file
        1. Getting ready
        2. Getting on with it
          1. Writing the loader
          2. Parsing levels from the file
          3. Parsing the desired level
          4. Recognizing ends of levels
          5. Processing each tile
        3. What did we do?
        4. What else do I need to know?
      4. Displaying the map contents
        1. Getting ready
        2. Getting on with it
          1. Adding the content layers
          2. Loading the world with a map
        3. What did we do?
        4. What else do I need to know?
      5. Adding the interface
        1. Getting ready
        2. Getting on with it
          1. Creating the Move requests
        3. What did we do?
      6. Making the game playable
        1. Getting ready
        2. Getting on with it
          1. Handling the Move inputs
          2. Displaying the effects of moves
        3. What did we do?
      7. Adding the Shell component
        1. Getting ready
        2. Getting on with it
          1. Counting levels
          2. Building the selection screen
          3. Presenting the table
        3. What did we do?
      8. Supporting Undo
        1. Getting on with it
          1. Recognizing the Undo requests
          2. Saving move history and backing moves out
        2. What did we do?
      9. Preserving game history
        1. Getting ready
        2. Getting on with it
          1. Controlling history selection
          2. Linking history to the game when loading
        3. What did we do?
      10. Game over – wrapping it up
      11. Can you take the HEAT? The Hotshot Challenge
    11. 3. TranslationBuddy – Fast App Development for any Field
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Summarizing the design
        1. Getting on with it
        2. What did we do?
      3. Creating the account
        1. Getting ready
        2. Getting on with it
        3. What did we do?
        4. What else do I need to know?
      4. Assembling the translator
        1. Getting ready
        2. Getting on with it
          1. Gatekeeping requests
          2. Consuming requests
          3. Maintaining authorization
          4. Linking the translation loop
          5. Handling the network requests
          6. Renewing the access token
        3. What did we do?
        4. What else do I need to know?
      5. Displaying results
        1. Getting ready
        2. Getting on with it
          1. Constructing the strata
          2. Adding the controls
          3. Preloading scene visuals
          4. Creating the list display
          5. Adding rows to the display
          6. Cleaning up the scene after each use
        3. What did we do?
      6. Soliciting input
        1. Getting ready
        2. Getting on with it
          1. Creating a backdrop
          2. Creating the text box
          3. Processing the user input
          4. Tying the pieces together
        3. What did we do?
      7. Maintaining a history
        1. Getting ready
        2. Getting on with it
          1. Viewing the history
          2. Enabling both views
          3. Keeping the effects clean
        3. What did we do?
        4. What else do I need to know?
      8. Game over – wrapping it up
      9. Can you take the HEAT? The Hotshot Challenge
    12. 4. Deep Black – Processing Mobile Device Input
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Creating the player and receiving events
        1. Getting ready
        2. Getting on with it
          1. Creating a placeholder world
          2. Preparing the physics simulation
          3. Setting up the ship object
          4. Attaching behaviors to the player ship
          5. Adding a library function
        3. What did we do?
      3. Processing raw physical events
        1. Getting ready
        2. Getting on with it
        3. What did we do?
      4. Bridging physical events to game events
        1. Getting ready
        2. Getting on with it
          1. Tracking time passage
        3. What did we do?
      5. Creating the world rules
        1. Getting ready
        2. Getting on with it
          1. Filling the visible field
          2. Managing the world bounds
          3. Generating random locations
          4. Clearing movable objects
        3. What did we do?
      6. Creating enemies and controlling collisions
        1. Getting ready
        2. Getting on with it
          1. Spawning enemies at game start
        3. What did we do?
      7. Responding to fire controls and creating bullets
        1. Getting ready
        2. Getting on with it
          1. Dispatching fire control events
          2. Responding to fire events
          3. Teleporting the player
        3. What did we do?
      8. Responding to collisions and handling lives
        1. Getting ready
        2. Getting on with it
          1. Clearing lasers that hit something
          2. Destroying asteroids
          3. Handling collisions with the player
        3. What did we do?
      9. Recognizing kills and recording scores
        1. Getting on with it
          1. Tracking lives
          2. Displaying lives and the score
        2. What did we do?
      10. Game over – wrapping it up
      11. Can you take the HEAT? The Hotshot Challenge
    13. 5. Atmosfall – Managing Game Progress with Coroutines
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Tracking progress through the level
        1. Getting ready
        2. Getting on with it
          1. Sliding the background
          2. Tracking the background progress
      3. Constructing the enemy behavior
        1. Getting on with it
          1. Creating an enemy
      4. Creating a schedule
        1. Getting on with it
          1. Building a schedule framework
          2. Building the scheduled actions
          3. Bringing an enemy to life
        2. What did we do?
        3. What else do I need to know?
      5. Scripting behavior
        1. Getting ready
        2. Getting on with it
          1. Writing a ship control script
          2. Defining ship actions
          3. Adding a new ship to the level
          4. Adding weapon fire
        3. What did we do?
        4. What else do I need to know?
      6. Controlling the boss
        1. Getting on with it
          1. Creating the boss object
          2. Making the boss module available
          3. Driving the boss's behavior
          4. Handling the boss's defeat
        2. What did we do?
        3. What else do I need to know?
      7. Cleaning up and making the game playable
        1. Getting on with it
          1. Adding challenges to the level
          2. Enabling finite lives
      8. Game over – wrapping it up
      9. Can you take the HEAT? The Hotshot Challenge
    14. 6. Predation – Creating Powerful Visuals from Simple Effects
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Planning the dissolve
        1. Getting ready
        2. Getting on with it
        3. What did we do?
      3. Applying the dissolve
        1. Getting ready
        2. Getting on with it
        3. What did we do?
        4. What else do I need to know?
      4. Planning the splatter
        1. Getting on with it
        2. What did we do?
      5. Assembling the splatter layers
        1. Getting ready
        2. Getting on with it
        3. What did we do?
        4. What else do I need to know?
      6. Game over – wrapping it up
      7. Can you take the HEAT? The Hotshot Challenge
    15. 7. Caves of Glory – Mastering Maps and Zones
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Parsing a level file
        1. Getting ready
        2. Getting on with it
          1. Splitting the level into map and object data
          2. Creating the map canvas
          3. Reading objects into the position data
        3. What did we do?
      3. Displaying objects
        1. Getting on with it
          1. Supplying visual descriptions of items
          2. Loading item visuals into the world
        2. What did we do?
        3. What else do I need to know?
      4. Creating an efficient background
        1. Getting on with it
          1. Loading background data from a level file
          2. Assembling the tile field
        2. What did we do?
        3. What else do I need to know?
      5. Scrolling around a large level
        1. Getting on with it
          1. Displaying the visible background
          2. Aligning the background with the screen
        2. What did we do?
      6. Interacting with objects
        1. Getting on with it
          1. Registering interactive objects with the world
          2. Adding interactivity to an object definition
        2. What did we do?
      7. Defining a chapter
        1. Getting ready
        2. Getting on with it
          1. Specifying a chapter's beginning and end
          2. Launching a selected chapter
          3. Tracking goal progress
        3. What did we do?
      8. Creating scenes for datafiles
        1. Getting on with it
          1. Scanning the chapter directory
          2. Launching the first scene
        2. What did we do?
        3. What else do I need to know?
      9. Linking scenes together
        1. Getting on with it
          1. Recognizing trigger movement
          2. Executing the level transition
        2. What did we do?
      10. Game over – wrapping it up
      11. Can you take the HEAT? The Hotshot Challenge
    16. 8. The Beat Goes On – Integrating with Game Networks
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Tracking multiple touches
        1. Getting ready
        2. Getting on with it
          1. Enabling multiple touches
          2. Creating a list
          3. Adding new entries to the list
          4. Updating entries in the list
          5. Clearing entries from the list
          6. Granting access to the list
        3. What did we do?
      3. Comparing touches with targets
        1. Getting ready
        2. Getting on with it
          1. Loading the touches module
          2. Matching touches to targets
          3. Adjusting the player's score
        3. What did we do?
      4. Loading and playing music
        1. Getting ready
        2. Getting on with it
          1. Finding the song file
          2. Playing the song file
          3. Closing the song file
        3. What did we do?
      5. Enabling Game Center on the Provisioning Portal
        1. Getting on with it
          1. Create the App ID
        2. What did we do?
      6. Enabling Game Center on iTunes Connect
        1. Getting ready
        2. Getting on with it
          1. Enabling Game Center
          2. Adding a leaderboard
        3. What did we do?
      7. Initializing a game network connection
        1. Getting ready
        2. Getting on with it
          1. Registering application load
          2. Tracking connection progress
          3. Requesting a Game Center connection
        3. What did we do?
        4. What else do I need to know?
      8. Updating and reading a leaderboard
        1. Getting ready
        2. Getting on with it
          1. Checking network availability
          2. Submitting a final score
          3. Displaying leaderboard values
        3. What did we do?
        4. What else do I need to know?
      9. Game over – wrapping it up
      10. Can you take the HEAT? The Hotshot Challenge
    17. 9. Into the Woods – Computer Navigation of Environments
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Structuring the A* algorithm
        1. Getting ready
        2. Getting on with it
          1. Assembling the requirements
          2. Selecting the cheapest choice
          3. Checking for completion
          4. Advancing the search
          5. Registering new or improved possibilities
        3. What did we do?
        4. What else do I need to know?
      3. Writing a custom iterator
        1. Getting ready
        2. Getting on with it
          1. Starting the loop
          2. Advancing the loop
          3. Preparing a loop
        3. What did we do?
        4. What else do I need to know?
      4. Selecting costs for neighboring tiles
        1. Getting ready
        2. Getting on with it
          1. Providing cost assignments
          2. Selecting costs for terrain types
          3. Forwarding the cost data
        3. What did we do?
        4. What else do I need to know?
      5. Sorting likely routes using a heap
        1. Getting ready
        2. Getting on with it
          1. Building the heap form
          2. Adding to the heap form
          3. Caching heuristic values
          4. Fixing heap
          5. Pulling a value
        3. What did we do?
        4. What else do I need to know?
      6. Writing a heuristic function
        1. Getting ready
        2. Getting on with it
          1. Constructing the function
        3. What did we do?
        4. What else do I need to know?
      7. Connecting all the elements
        1. Getting ready
        2. Getting on with it
          1. Assembling dependencies
          2. Binding the components
        3. What did we do?
      8. Using the implementation to find a path
        1. Getting ready
        2. Getting on with it
          1. Monitoring while idle
          2. Responding with pursuit
        3. What did we do?
      9. Moving based on path selection
        1. Getting ready
        2. Getting on with it
        3. What did we do?
      10. Game over – wrapping it up
      11. Can you take the HEAT? The Hotshot Challenge
    18. 10. Underfoot – Selectively Leveraging the Physics System
      1. What do we build?
        1. What does it do?
        2. Why is it great?
        3. How are we going to do it?
        4. What do I need to get started?
      2. Building physics for the map
        1. Getting ready
        2. Getting on with it
          1. Defining the floor category
          2. Clearing the map
          3. Scanning the rows and identifying block runs
          4. Creating the blocks
        3. What did we do?
        4. What else do I need to know?
      3. Making characters interact with the world
        1. Getting ready
        2. Getting on with it
          1. Defining the character body category
          2. Adding a body to characters
        3. What did we do?
        4. What else do I need to know?
      4. Responding to collisions with other characters
        1. Getting ready
        2. Getting on with it
          1. Defining categories for enemies and the player
          2. Applying categories to bodies
          3. Reacting to collision events
        3. What did we do?
        4. What else do I need to know?
      5. Bouncing off enemies as appropriate
        1. Getting on with it
          1. Checking for foot-head contact
        2. What did we do?
        3. What else do I need to know?
      6. Controlling gravity to enable climbing
        1. Getting on with it
          1. Tracking contact with ladder regions
          2. Detecting available ladders
          3. Negating Gravity when Climbing
          4. Restoring gravity when releasing a ladder
        2. What did we do?
      7. Selecting collisions by manipulating contacts
        1. Getting on with it
          1. Specializing the floor object
          2. Checking the direction
          3. Disabling the collision
        2. What did we do?
        3. What else do I need to know?
      8. Adding polish with custom fonts
        1. Getting ready
        2. Getting on with it
          1. Using a font in your app
          2. Registering the font with iOS
        3. What did we do?
        4. What else do I need to know?
      9. Game over – wrapping it up
      10. Can you take the HEAT? The Hotshot Challenge
    19. Index