Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Corona SDK Mobile Game Development: Beginner's Guide

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product type Book
Published in Mar 2015
Publisher
ISBN-13 9781783559343
Pages 372 pages
Edition 1st Edition
Languages
Author (1):
Michelle M Fernandez Michelle M Fernandez
Profile icon Michelle M Fernandez

Table of Contents (19) Chapters

Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with Corona SDK Lua Crash Course and the Corona Framework Building Our First Game – Breakout Game Controls Animating Our Game Playing Sounds and Music Physics – Falling Objects Operation Composer Handling Multiple Devices and Networking Your Apps Optimizing, Testing, and Shipping Your Games Implementing In-App Purchases Pop Quiz Answers Index

Time for action – drawing the background


In this section, we'll fill the screen with our environment display objects. This includes our background and ground objects, and we can also add physical elements to our ground so that we can designate collision events for it. To draw the background, perform the following steps:

  1. Create a local function called drawBackground():

        local drawBackground = function()
  2. Add in the background image:

          background = display.newImageRect( "bg.png", 480, 320 )
          background.x = 240; background.y = 160
          gameGroup:insert( background )
  3. Add in the ground elements and create the ground physical boundary. Close the function:

          ground = display.newImageRect( "grass.png", 480, 75 )
          ground.x = 240; ground.y = 325
          ground.myName = "ground"
          local groundShape = { -285,-18, 285,-18, 285,18, -285,18}
          physics.addBody( ground, "static", { density=1.0, bounce=0, friction=0.5, shape=groundShape } )
          gameGroup:insert( ground )
        end

What...

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 $15.99/month. Cancel anytime}