Game Development Reference
In-Depth Information
And here's the code for Gideros Studio:
function newText(theText, xPos, yPos, theFontName, theFontSize)
local xPos, yPos = xPos or 0, yPos or 0
local theFontSize = theFontSize or 24
local theFontName = theFontName or "Helvetica.ttf"
local _font = TTFont.new(theFontName, theFontSize)
local _text = TextField.new(_font, theText)
_text.width = _text:getWidth()
_text.height= _text:getHeight()
stage:addChild(_text)
position(_text, xPos, yPos - _text.height) -- Gideros uses baseline font
return _text
newText function, which creates our text items, we can create the function to
if theObject == nil then return end
theObject.text = theNewText or ""
And here's the code for Gideros Studio:
function updateText(theObject, theNewText)
if theObject == nil then return end
theObject:setText(theNewText or "")
end
Next we can create the HUD items.
Here's the Corona SDK code:
local textLine = baseLine + 10
And here's the Gideros Studio code:
local textLine = baseLine + 55
local txtLives, txtFuel, txtSaved, txtScore, txtGameOver, txtTapAgain
function createHUDItems()
-- create the items lives, fuel, saved, score, and game-over text
txtLives = newText(lives, 170, textLine)
txtFuel = newText(fuel, 610, textLine)
txtSaved = newText(collected, 840, textLine)
txtScore = newText(score, 410, textLine)
txtGameOver = newText("G a m e O v e r", 0, 0)
Search WWH ::




Custom Search