【发布时间】:2013-06-04 15:32:46
【问题描述】:
当我通过分配“if”条件创建函数时不起作用,但是当我像下面的第二个示例那样创建函数时,它会起作用。你能告诉我为什么吗?
不工作:
local start=os.time()
local countDown = function(event)
if((os.time()-start)==3) then
Runtime: removeEventListener("enterFrame", countDown)
end
print(os.time()-start)
end
Runtime:addEventListener("enterFrame", countDown)
工作:
local start=os.time()
local function countDown(event)
if((os.time()-start)==3) then
Runtime: removeEventListener("enterFrame", countDown)
end
print(os.time()-start)
end
Runtime:addEventListener("enterFrame", countDown)
【问题讨论】: