我目前正在CoronaSDK(Lua)制作一个简单的应用程序,但我遇到了一些问题:
代码:
function points(num)
tmr = timer.performWithDelay(1000, points, 0)
num = 5
score = 2
score = score + num
scoreTxt.text = "score: " .. score
scoreTxt:setReferencePoint(display.TopLeftReferencePoint)
scoreTxt.x = screenLeft + 15
end
真的不知道放timer.cancel(tmr)
function explode()
timer.cancel(tmr)
explosion.x = jet.x
explosion.y = jet.y
explosion.isVisible = true
explosion:play()
jet.isVisible = false
timer.performWithDelay(3000, gameOver, 1)
end
function onCollision(event)
if event.phase == "began" then
if jet.collided == false then
timer.cancel(tmr)
num = nil;
score = nil;
jet.collided = true
jet.bodyType = "static"
explode()
end
end
end
更多信息不知道您是否需要它:P
score = 1.5;
num = 1;
scoreTxt = display.newText ("Score:", 0, 0, "Helvetica", 20)
scoreTxt:setReferencePoint(display.TopLeftReferencePoint)
scoreTxt.x = display.screenOriginX + 10
scoreTxt.y = display.screenOriginX + 5
screenLeft = display.screenOriginX
如果有人可以帮助我,我会非常感激:) 提前致谢
答案 0 :(得分:1)
tmr = timer.performWithDelay(1000, points, 0)
这一行中的点函数可以进行无限的函数调用。这是泄漏的原因。如果你想每秒调用点函数,你应该从其他地方调用它。