Game Development Reference
In-Depth Information
To get the width and height of the device, you can use the following in Corona SDK:
local _W, _H = display.contentWidth, display.contentHeight
and the following in Gideros Studio:
local _W, _H = application:getDeviceWidth(), application:getDeviceHeight()
_H, _W = _W, _H
Note Under Gideros, the height and width of the device is always returned in reference to the
Portrait orientation. Because this game is going to run in Landscape orientation, we need to swap
the height and width.
We also set up a few other variables that will be useful throughout the game:
local MAX_BULLETS = 5 -- the maximum number of bullets you can shoot
local MAX_FUEL = 500 -- the amount of fuel that you get when you refuel
local MAX_LIVES = 3 -- the maximum number of lives
local lives = MAX_LIVES -- the maximum number of tries
local fuel = MAX_FUEL -- the maximum amount of fuel available
local score = 0
local distance = 0
local hiscore = 0
local collected = 0
local filter = 0.8
local gameover = false
We set the following for Corona SDK:
local NORMAL = 6 -- the normal speed for things that move
local FAST = 12 -- the speed of things that move fast
and the following for Gideros Studio:
local NORMAL = 3 -- the normal speed for things that move
local FAST = 6 -- the speed of things that move fast
local TOPLINE = 100
local BOTTOMLINE = 500
local random = math.random
local floor = math.floor
local background
We also set the following for Corona SDK:
local performAfter = timer.performWithDelay
background = display.newRect(0,0,_W,_H)
background:setFillColor(255,255,255)
Search WWH ::




Custom Search