You are previewing Corona SDK Mobile Game Development.
O'Reilly logo
Corona SDK Mobile Game Development

Book Description

You don’t need to be a programming whiz to create iOS and Android games. You just need this great hands-on guide to Corona SDK, which teaches you everything from game physics to successful marketing.

  • Build once and deploy your games to both iOS and Android

  • Create commercially successful games by applying several monetization techniques and tools

  • Create three fun games and integrate them with social networks such as Twitter and Facebook

  • In Detail

    Corona SDK is the fastest and easiest way to create commercially successful cross platform mobile games. Just ask Robert Nay, a 14 year old who created Bubble Ball - downloaded three million times, famously knocking Angry Birds off the top spot. You don’t need to be a programming veteran to create games using Corona. Corona SDK is the number one tool for creating fun, simple blockbuster games.

    Assuming no experience at all with programming or game development you will learn the basic foundations of Lua and Corona right through to creating several monetized games deployable to Android and Apple stores.

    You will begin with a crash course in Lua, the programming language underpinning the Corona SDK tool. After downloading and installing Corona and writing some simple code you will dive straight into game development. You will start by creating a simple breakout game with controls optimized for mobile. You will build on this by creating two more games incorporating different features such as falling physics. The book ends with a tutorial on social network integration, implementing in app purchase and most important of all monetizing and shipping your game to the Android and App stores.

    Table of Contents

    1. Corona SDK Mobile Game Development
      1. Corona SDK Mobile Game Development
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Time for action – heading
          1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      7. 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 your 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
      8. 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)
          4. Assignment conventions
        3. Types of values
        4. Time for action – printing values using blocks
          1. What just happened?
        5. Expressions
          1. Arithmetic operators
          2. Relational operators
          3. Logical operators
          4. Concatenation
          5. Length operator
          6. Precedence
        6. Strings
          1. Quoting strings
        7. Time for action – getting our hands full of strings
          1. What just happened?
          2. Have a go hero – pulling some more strings
        8. Tables
          1. Passing a table as an array
          2. Altering contents in a table
          3. Populating a table
        9. Objects
          1. Display objects
          2. Display properties
          3. Object methods
        10. Images
          1. Loading an image
          2. Image autoscaling
        11. Time for action – placing images on screen
          1. What just happened?
          2. Have a go hero – adjusting display object properties
        12. Runtime configuration
          1. Dynamic content scaling
          2. Dynamic content alignment
          3. Dynamic image resolution
          4. Frame rate control and anti-aliasing
        13. Time for action – scaling display objects on multiple devices
          1. What just happened?
          2. Dynamic resolution images
        14. Time for some shapes
          1. Applying stroke width, fill color, and stroke color
          2. Text, text, text
          3. Applying color and string value
        15. Functions
          1. Defining a function
          2. More display functions
          3. Content size properties
        16. Optimizing your workflow
          1. Using memory efficiently
          2. Optimizing your display images
          3. Pop quiz – basics of Lua
        17. Summary
      9. 3. Building our First Game: Breakout
        1. Breakout—bringing back old-school gaming
        2. Understanding Corona physics API
          1. Setting up the physics world
            1. Starting, pausing, and stopping physics
            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 build.settings file
          1. What just happened?
          2. Runtime configuration
        5. Time for action – adding 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 gameplay 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
      10. 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 accelerometer
          1. What just happened?
        7. Ball collision with 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
      11. 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. Movieclips or sprite sheets. What's the difference?
        5. Movieclips
          1. Movieclip functions
        6. It's sprite mania!
          1. Sprite API
        7. Game time!
        8. Time for action – setting up the variables
          1. What just happened?
        9. Let's start the round
        10. Time for action – starting the game
          1. What just happened?
        11. Poof begone!
        12. Time for action – reloading the panda on the stage
          1. What just happened?
        13. Earn some points
        14. Time for action – tracking the score
          1. What just happened?
        15. When the game ends
        16. Time for action – displaying the game over screen
          1. What just happened?
        17. Background display
        18. Time for action – adding the background elements
          1. What just happened?
        19. Heads up!
        20. Time for action – displaying the timer and score
          1. What just happened?
        21. Time after time
        22. Time for action – setting up the timer
          1. What just happened?
        23. It's so glowy
        24. Time for action – making the power shot
          1. What just happened?
        25. Pandas!
        26. Time for action – creating the panda character
          1. What just happened?
        27. Starry skies
        28. Time for action – creating star collisions
          1. What just happened?
          2. Have a go hero – tracking the star count
        29. Screen touches
        30. Time for action – launching the panda
          1. What just happened?
        31. Organizing display objects
        32. Time for action – reordering layers
          1. What just happened?
        33. Create stars
        34. Time for action – creating stars in the level
          1. What just happened?
          2. Have a go hero – creating a movieclip
        35. Starting the game
        36. Time for action – initializing the game
          1. What just happened?
          2. Pop quiz – animating graphics
        37. Summary
      12. 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. Pre-loading phase
          2. audioPlayFrequency
          3. Patents and royalties
          4. Pop quiz – all about audio
        9. Summary
      13. 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 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 post-collisions
            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 gameplay
        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
      14. 8. Operation Storyboard
        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. Storyboard API
          1. Game development with Storyboard 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
      15. 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 resolutions
          4. High-resolution sprite sheets
        2. Networking your apps
          1. Posting to Twitter
        3. Time for action – adding Twitter in 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
        7. The wonders of OpenFeint
          1. Game network API
            1. gameNetwork.init()
            2. gameNetwork.show()
            3. gameNetwork.request()
        8. OpenFeint in a jiffy
        9. Time for action – setting up OpenFeint leaderboards and achievements in Egg Drop
          1. What just happened?
          2. Have a go hero – adding more OpenFeint achievements
          3. Pop quiz – handling social networks
        10. Summary
      16. 10. Optimizing, Testing, and Shipping your Games
        1. Understanding memory efficiency
          1. Graphics
            1. Group objects
            2. Turn 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 to 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
      17. 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
      18. 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 Storyboard
          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