I quite new at LUA. I am using timer to popup alerts, made up with displaygroup, when necessary. To remove them I'm using timeperformwithdelay function that calls a remove function which removes the displaygroup object referencing with Self. However I have a stopwatch working with the timer function as well. When the stopwatch is zero I popup the Alert and after 2 seconds I want to remove it. But in this case the remove function does not work. Following is the code:
if timerleft==0 then
screenalert("Game 1","Time is over")
performwithdelay(2000,remove,1)
end
Thanks Hi there again, thanks for your support. Here is my code:
local function timerDown()
timeLimit = timeLimit-1
if timeLimit < 10 then
timeLeft.text = "0:0"..timeLimit
else
timeLeft.text = "0:"..timeLimit
end
if(timeLimit==0)then
timeLeft.text="0:00"
alertScreen("Game 1","Time is over!")
timer.performWithDelay(2000,removeAlert,1)
timeLimit=60
end
end
local function removeAlert()
alertDisplayGroup:removeSelf()
end
function alertScreen(title, message)
alertBox=display.newImage("cornice.png")
alertBox.x=W
alertBox.y=H/1.3
titolomessaggio=display.newText(title,0,0,"Arial",200)
titolomessaggio:setTextColor(255,255,0,255)
titolomessaggio.xScale=0.5
titolomessaggio.yScale=0.5
titolomessaggio.x=display.contentCenterX
titolomessaggio.y=display.contentCenterY-200
testomessaggio=display.newText(message,0,0,"Arial",100)
testomessaggio:setTextColor(255,255,0,255)
testomessaggio.xScale=0.5
testomessaggio.yScale=0.5
testomessaggio.x=display.contentCenterX
testomessaggio.y=display.contentCenterY+10
alertDisplayGroup=display.newGroup()
alertDisplayGroup:insert(alertBox)
alertDisplayGroup:insert(titolomessaggio)
alertDisplayGroup:insert(testomessaggio)
end
removefunction do? What does it expect to operate on because I can't imagine it gets any context or arguments when called that way. - Etan Reisnerremovefunction look like? Does it take an argument? Is it a "member" function of some object/table? - Etan Reisner