You are previewing Corona SDK Mobile Game Development : Beginner's Guide - Second Edition.
O'Reilly logo
Corona SDK Mobile Game Development : Beginner's Guide - Second Edition

Book Description

Learn, explore, and create commercially successful mobile games for iOS and Android

In Detail

Corona is a software development kit to build mobile applications for iPhone, iPad, and Android devices.

This book will take you through the journey of developing games right from installing Corona SDK and creating Hello World as your first app. Going further, you will learn how to script in Lua and learn some techniques to apply this in Corona SDK with demonstration. Towards the end of the book you'll build the final game, which involves physical objects and also uses features such as the accelerometer. Moreover, learn to make your game socially available on Twitter and Facebook.

By the end of the book, you'll learn to deploy your iOS and Android games to the App Store and Google Play Store.

What You Will Learn

  • Learn how to script in Lua and get a better understanding of command flow, functions, and objects

  • Load images and add a background image to your games

  • Apply more functionality to your game using more APIs

  • Use sprite sheets and create more complex game logic for the game

  • Track your data and save the scores of your games

  • Make your game socially aware by sharing messages and scores on Facebook and Twitter

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Corona SDK Mobile Game Development Beginner's Guide Second Edition
      1. Table of Contents
      2. Corona SDK Mobile Game Development Beginner's Guide Second Edition
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
        5. Time for action – heading
          1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        6. Conventions
        7. Reader feedback
        8. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Getting Started with Corona SDK
        1. Downloading and installing Corona
        2. Time for action – setting up and activating Corona on Mac OS X
          1. What just happened?
        3. Time for action – setting up and activating Corona on Windows
          1. What just happened?
        4. Using the simulator on Mac and Windows
        5. Time for action – viewing a sample project in the simulator
          1. What just happened?
          2. Have a go hero – use a different device shell
        6. Choosing a text editor
        7. Developing on devices
        8. Time for action – downloading and installing Xcode
          1. What just happened?
        9. Time for action – creating a Hello World application in two lines of code
        10. Time for action – modifying our application
        11. Time for action – applying a new font name to our application
          1. What just happened?
          2. Have a go hero – adding more text objects
        12. Testing our application on an iOS device
        13. Time for action – obtaining the iOS developer certificate
          1. What just happened?
          2. Adding iOS devices
            1. Xcode
            2. iTunes
        14. Time for action – adding/registering your iOS device
        15. Time for action – creating an App ID
          1. What just happened?
          2. Provisioning profiles
        16. Time for action – creating a provisioning profile
          1. What just happened?
          2. Application icon
        17. Creating the Hello World build for iOS
        18. Time for action – creating an iOS build
          1. What just happened?
        19. Time for action – loading an app on your iOS device
          1. What just happened?
        20. Testing our application on an Android device
        21. Creating the Hello World build for Android
        22. Time for action – creating an Android build
          1. What just happened?
        23. Time for action – loading an app on your Android device
          1. What just happened?
          2. Pop quiz – understanding Corona
        24. Summary
      9. 2. Lua Crash Course and the Corona Framework
        1. Lua to the rescue
        2. Valuable variables
          1. Global variables
          2. Local variables
          3. Table fields (properties)
        3. Assignment conventions
        4. Types of values
        5. Time for action – printing values using blocks
          1. What just happened?
        6. Expressions
          1. Arithmetic operators
          2. Relational operators
          3. Logical operators
          4. Concatenation
          5. The length operator
          6. Precedence
        7. Strings
          1. Quoting strings
        8. Time for action – getting our hands full of strings
          1. What just happened?
          2. Have a go hero – pulling some more strings
        9. Tables
          1. Passing a table as an array
          2. Altering contents in a table
          3. Populating a table
        10. Objects
          1. Display objects
          2. Display properties
          3. Object methods
        11. Images
          1. Loading an image
          2. Image autoscaling
        12. Time for action – placing images on screen
          1. What just happened?
          2. Have a go hero – adjusting display object properties
        13. Runtime configuration
          1. Dynamic content scaling
          2. Dynamic content alignment
          3. Dynamic image resolution
          4. Frame rate control
        14. Time for action – scaling display objects on multiple devices
          1. What just happened?
        15. Dynamic resolution images
          1. Time for some shapes
            1. Applying stroke width, fill color, and stroke color
          2. Text, text, text
            1. Applying color and string value
        16. What are functions?
          1. Defining a function
          2. More display functions
            1. Content size properties
        17. Optimize your workflow
          1. Use memory efficiently
        18. Optimize your display images
          1. Pop quiz – basics of Lua
        19. Summary
      10. 3. Building Our First Game – Breakout
        1. Breakout – bringing back old-school gaming
        2. Understanding the Corona physics API
          1. Setting up the physics world
            1. Starting, pausing, and stopping the physics engine
            2. physics.setGravity
            3. physics.getGravity
            4. Tilt-based gravity
            5. physics.setScale
            6. physics.setDrawMode
            7. physics.setPositionIterations
            8. physics.setVelocityIterations
        3. Configuring the application
          1. Build configuration
        4. Time for action – adding the build.settings file
          1. What just happened?
          2. Dynamic scaling
        5. Time for action – adding the config.lua file
          1. What just happened?
        6. Building the application
          1. Displaying groups
            1. display.newGroup()
          2. Working with system functions
            1. system.getInfo()
            2. system.setAccelerometerInterval()
        7. Time for action – creating variables for the game
          1. What just happened?
        8. Understanding events and listeners
          1. Register events
          2. Runtime events
            1. enterFrame
            2. Accelerometer
          3. Touch events
            1. Touch (single touch)
            2. tap
        9. Transitions
        10. Creating menu screens
        11. Time for action – adding the main menu screen
          1. What just happened?
          2. Have a go hero – creating a help screen
        12. Creating the game play scene
        13. Time for action – adding game objects
          1. What just happened?
        14. Time for action – building bricks
          1. What just happened?
          2. Have a go hero – focused platform gaming
        15. Red alert!
        16. Time for action – displaying game messages
          1. What just happened?
          2. Pop quiz – building a game
        17. Summary
      11. 4. Game Controls
        1. Moving in the up direction
        2. Let's get even more physical
          1. physics.addBody()
        3. Time for action – starting physics for the paddle and ball
          1. What just happened?
        4. Paddle movement
        5. Time for action – dragging the paddle in the simulator
          1. What just happened?
        6. Time for action – moving the paddle with the accelerometer
          1. What just happened?
        7. Ball collision with the paddle
        8. Time for action – making the ball bounce against the paddle
          1. What just happened?
        9. Removing objects from the scene
          1. Variable references
        10. Brick by brick
        11. Time for action – removing the bricks
          1. What just happened?
        12. Directional changes
        13. Time for action – updating the ball
          1. What just happened?
        14. Transitioning levels
        15. Time for action – resetting and changing levels
          1. What just happened?
          2. Have a go hero –add more levels
        16. You win some, you lose some
        17. Time for action –making win and lose conditions
          1. What just happened?
        18. Activating event listeners
          1. Collision events
            1. Global collision listeners
            2. Local collision listeners
        19. Time for action – adding game listeners
          1. What just happened?
          2. Have a go hero – let's turn everything upside down
        20. The results are in!
          1. Pop quiz – working with game controls
        21. Summary
      12. 5. Animating Our Game
        1. Panda Star Catcher
        2. Let's get everything moving
          1. Transitions
          2. Easing
        3. The value of timed functions
          1. Timers
        4. What are image sheets?
        5. It's sprite mania!
          1. Image sheet API
        6. Game time!
        7. Time for action – setting up the variables
          1. What just happened?
        8. Let's start the round
        9. Time for action – starting the game
          1. What just happened?
        10. Poof! Be gone!
        11. Time for action – reloading the panda on the stage
          1. What just happened?
        12. Earning some points
        13. Time for action – tracking the score
          1. What just happened?
        14. When the game ends
        15. Time for action – displaying the game over screen
          1. What just happened?
        16. Background display
        17. Time for action – adding the background elements
          1. What just happened?
        18. Heads up!
        19. Time for action – displaying the timer and score
          1. What just happened?
        20. Time after time
        21. Time for action – setting up the timer
          1. What just happened?
        22. It's so glowy
        23. Time for action – making the power shot
          1. What just happened?
        24. Pandas!
        25. Time for action – creating the panda character
          1. What just happened?
        26. Starry skies
        27. Time for action – creating star collisions
          1. What just happened?
          2. Have a go hero – tracking the star count
        28. Screen touches
        29. Time for action – launching the panda
          1. What just happened?
        30. Organizing display objects
        31. Time for action – reordering layers
          1. What just happened?
        32. Creating stars
        33. Time for action – creating stars in the level
          1. What just happened?
        34. Starting the game
        35. Time for action – initializing the game
          1. What just happened?
          2. Pop quiz – animating graphics
        36. Summary
      13. 6. Playing Sounds and Music
        1. Corona audio system
          1. Sound formats
          2. Sound filename limitations on Android
          3. Mono sounds at their best
          4. Maximum number of simultaneous channels
        2. Time to play
          1. audio.loadSound()
          2. audio.loadStream()
          3. audio.play()
          4. Looping
          5. Simultaneous playback
        3. Time for action – playing audio
          1. What just happened?
          2. Have a go hero – repeating audio with delay
        4. Time to take control
          1. audio.stop()
          2. audio.pause()
          3. audio.resume()
          4. audio.rewind()
        5. Time for action – controlling audio
          1. What just happened?
        6. Memory management
          1. audio.dispose()
          2. Have a go hero – disposing audio
        7. Alterations to audio
          1. Volume control
            1. audio.setVolume()
            2. audio.setMinVolume()
            3. audio.setMaxVolume()
            4. audio.getVolume()
            5. audio.getMinVolume()
            6. audio.getMaxVolume()
          2. Fading audio
            1. audio.fade()
            2. audio.fadeOut()
        8. Performance tips
          1. Preloading phase
          2. audioPlayFrequency
          3. Patents and royalties
          4. Pop quiz – all about audio
        9. Summary
      14. 7. Physics – Falling Objects
        1. Creating our new game – Egg Drop
          1. Starting variables
        2. Time for action – setting up the variables
          1. What just happened?
          2. Controlling the main character
        3. Time for action – moving the character
          1. What just happened?
          2. Have a go hero – adding touch events
          3. Updating the score
        4. Time for action – setting the score
          1. What just happened?
          2. Displaying the game environment
        5. Time for action – drawing the background
          1. What just happened?
          2. Displaying the heads-up display
        6. Time for action – designing the HUD
          1. What just happened?
          2. Creating the game lives
        7. Time for action – counting the lives
          1. What just happened?
          2. Have a go hero – adding images for the game lives
          3. Introducing the main character
            1. Complex body construction
        8. Time for action – creating the character
          1. What just happened?
          2. Adding postcollisions
            1. Collision handling
          3. Body properties
            1. body.isAwake
            2. body.isBodyActive
            3. body.isBullet
            4. body.isSensor
            5. body.isSleepingAllowed
            6. body.isFixedRotation
            7. body.angularVelocity
            8. body.linearDamping
            9. body.angularDamping
            10. body.bodyType
        9. Time for action – creating the egg collision
          1. What just happened?
          2. Making the display objects fall
        10. Time for action – adding the egg object
          1. What just happened?
        11. Time for action – making the egg drop
          1. What just happened?
          2. Ending the game play
        12. Time for action – calling game over
          1. What just happened?
          2. Starting the game
        13. Time for action – activating the game
          1. What just happened?
          2. Pop quiz – animating the graphics
        14. Summary
      15. 8. Operation Composer
        1. Continuation of Egg Drop
        2. Data saving
          1. BeebeGames class for saving and loading values
          2. Getting paths to files
          3. Reading files
          4. Writing files
        3. Time for action – saving and loading the high score
          1. What just happened?
        4. Pausing the game
        5. Time for action – pausing the game
          1. What just happened?
        6. The Composer API
          1. Game development with the Composer API
        7. Time for action – altering the game file
          1. What just happened?
        8. Organizing the game
        9. Time for action – adding the new main.lua file
          1. What just happened?
        10. New game transitions
        11. Time for action – changing screens after the game is over
          1. What just happened?
          2. Have a go hero – restarting the game
        12. Creating a loading screen
        13. Time for action – adding the loading screen
          1. What just happened?
        14. Creating a main menu
        15. Time for action – adding a main menu
          1. What just happened?
        16. Creating an options menu
        17. Time for action – adding an options menu
          1. What just happened?
        18. Creating a credits screen
        19. Time for action – adding a credits screen
          1. What just happened?
          2. Have a go hero – adding more levels
          3. Pop quiz – game transitions and scenes
        20. Summary
      16. 9. Handling Multiple Devices and Networking Your Apps
        1. Return to configuration
          1. Build configuration
            1. Orientation support (iOS)
            2. Orientation support (Android)
            3. Version code and version name (Android)
            4. Application permissions (Android)
          2. Content scaling on an easier level
            1. The best of both worlds
          3. The deeper meaning of dynamic image selection
          4. High-resolution sprite sheets
        2. Networking your apps
          1. Posting to Twitter
        3. Time for action – adding Twitter to your apps
          1. What just happened?
          2. Posting to Facebook
        4. Time for action – adding Facebook to your apps
          1. What just happened?
        5. Facebook Connect
        6. Time for action – posting scores using Facebook Connect
          1. What just happened?
          2. Have a go hero – create a dialog box
          3. Pop quiz – handling social networks
        7. Summary
      17. 10. Optimizing, Testing, and Shipping Your Games
        1. Understanding memory efficiency
          1. Graphics
            1. Group objects
            2. Turning off animations when they're not being used
            3. Optimizing image sizes
        2. Distributing iOS applications
          1. Prepping your app icons
        3. Time for action – setting up your distribution certificate and provisioning profile for the App Store
          1. What just happened?
        4. iTunes Connect
          1. Contracts, tax, and banking
        5. Time for action – managing your application in iTunes Connect
          1. What just happened?
        6. Building an iOS application for distribution in Corona
        7. Time for action – building your application and uploading it to the Application Loader
          1. What just happened?
          2. Have a go hero – making a universal iOS build
        8. The Google Play Store
          1. Creating launcher icons
        9. Time for action – signing your app for the Google Play Store
          1. What just happened?
        10. Time for action – submitting an app to the Google Play Store
          1. What just happened?
          2. Have a go hero – adding more promos
          3. Pop quiz – publishing applications
        11. Summary
      18. 11. Implementing In-App Purchases
        1. The wonders of In-App Purchase
          1. Types of In-App Purchases
        2. Corona's store module
          1. store.init()
            1. event.transaction
          2. store.loadProducts()
            1. event.products
            2. event.invalidProducts
          3. store.canMakePurchases
          4. store.purchase()
          5. store.finishTransaction()
          6. store.restore()
        3. Create an In-App Purchase
        4. Time for action – creating the In-App Purchase in iTunes Connect
          1. What just happened?
        5. Time for action – using the Corona store module to create an In-App Purchase
          1. What just happened?
          2. Have a go hero – handling multiple Product IDs
        6. Testing In-App Purchases
          1. User test accounts
        7. Time for action – testing the In-App Purchase with the Breakout In-App Purchase Demo
          1. What just happened?
          2. Have a go hero – using other In-App Purchase types
          3. Pop quiz – all about In-App Purchases
        8. Summary
      19. A. Pop Quiz Answers
        1. Chapter 1 – Getting Started with Corona SDK
          1. Pop quiz – understanding Corona
        2. Chapter 2 – Lua Crash Course and the Corona Framework
          1. Pop quiz – basics of Lua
        3. Chapter 3 – Building Our First Game – Breakout
          1. Pop quiz – building a game
        4. Chapter 4 – Game Controls
          1. Pop quiz – working with game controls
        5. Chapter 5 – Animating Our Game
          1. Pop quiz – animating graphics
        6. Chapter 6 – Playing Sounds and Music
          1. Pop quiz – all about audio
        7. Chapter 7 – Physics – Falling Objects
          1. Pop quiz – animating the graphics
        8. Chapter 8 – Operation Composer
          1. Pop quiz – game transitions and scenes
        9. Chapter 9 – Handling Multiple Devices and Networking Your Apps
          1. Pop quiz – handling social networks
        10. Chapter 10 – Optimizing, Testing, and Shipping Your Games
          1. Pop quiz – publishing applications
        11. Chapter 11 – Implementing In-App Purchases
          1. Pop quiz – all about In-App Purchases
      20. Index