So I tried to clear up my scripts by creating modules, but somehow it seems, that my Memory increased by 100Mb with just slightly modified code?! how can this be. What am I doing wrong? I try to make everything local…
Thanks for the Help guys, I really am stuck…
local M = {}
local function hud ()
local hudGrp = display.newGroup()
local timeStart = 0
local timeFinish
local HUDRect = display.newRect( 0, 0, display.contentWidth, 25)
HUDRect:setFillColor(0, 0, 0, 125)
local lifeTxt = display.newText ( LIFE…"/"…MAXLIFE) , 30, 47, Arial, 12 )
lifeTxt.x = 40
lifeTxt.y = lifeTxt.y - 42
local timeTxt = display.newText ( (“0s”) , 30, 47, Arial, 12 )
timeTxt.x = display.contentWidth/2
timeTxt.y = timeTxt.y - 42
local xpTxt = display.newText ( “0xp”, 30, 47, Arial, 12 )
xpTxt.x = display.contentWidth - 40
xpTxt.y = xpTxt.y - 42
–
local function changeLifeTxt ( text )
lifeTxt.text = text
end
M.changeLifeTxt = changeLifeTxt
–
local function changeXPTxt ( text )
xpTxt.text = text
end
M.changeXPTxt = changeXPTxt
–
local function changeTimeStart ( time )
timeStart = time
end
M.changeTimeStart = changeTimeStart
–
local function getTimeFinish ( )
return timeFinish
end
M.getTimeFinish = getTimeFinish
–
local function runTime ( event )
local timeEnd = event.time
timeFinish = (math.round(math.abs((timeEnd - timeStart)/100)))/10
--timeTxt:setReferencePoint( displayTopLeftReferencePoint )
timeTxt.text = (timeFinish… “s”)
end
M.runTime = runTime
–
hudGrp:insert( HUDRect )
hudGrp:insert( timeTxt )
hudGrp:insert( lifeTxt )
hudGrp:insert( xpTxt )
return hudGrp
end
M.hud = hud
return M