Let's start off with introducing all the variables needed to run the game:
main.lua
file and add it in the Panda Star Catcher
project folder.display.setStatusBar( display.HiddenStatusBar ) -- Hides the status bar in iOS only -- Display groups local hudGroup = display.newGroup() -- Displays the HUD local gameGroup = display.newGroup() local levelGroup = display.newGroup() local stars = display.newGroup() -- Displays the stars -- Modules local physics = require ("physics") local mCeil = math.ceil local mAtan2 = math.atan2 local mPi = math.pi local mSqrt = math.sqrt -- Game Objects local background local ground local powerShot local arrow local panda local poof local starGone local scoreText local gameOverDisplay -- Variables local gameIsActive = false local waitingForNewRound local restartTimer local counter local timerInfo local numSeconds = 30 -- Time the round starts at local counterSize = 50 local gameScore = 0 -- Round starts at a score of 0 local starWidth = 30 local starHeight = 30
We hid the status bar at the start of the application. This is only applicable for iOS devices. There are four different groups set up, and all of them play an important role in the game.
Notice that gameIsActive
is set as false
. This enables us to activate properties of the application to affect the round when the display objects need to stop animating, appear on screen, and become affected by touch events.
The elements for the timer have also been set in the beginning of the code as well. Setting numSeconds
to 30
denotes how long the round will count down from, in seconds. starWidth
and starHeight
depict the dimensions of the object.