如何检查功能是否正在进行中?如果它还没有进展,我希望它重复一遍。
local function move(event)
ball.x = 100
ball.y = 200
transition.to(ball, {x=0, y=600, time = 5000})
end
local function check(event)
if( --THE OTHER FUNCTION IS IN PROGRESS)then
--do something
end
end
ball:addEventListener("touch", move)
答案 0 :(得分:3)
我没有使用过电晕,但这是一种常见的javascript习惯用法,通常是你在那里做的方式:
local currentlyMoving = false
local function move(event)
ball.x = 100
ball.y = 200
currentlyMoving = true
transition.to(
ball,
{
x=0,
y=600,
time = 5000,
onComplete = function(obj)
currentlyMoving = false
end
})
end
local function check(event)
if (not currentlyMoving) then
--do something
end
end
ball:addEventListener("touch", move)
您可以找到有关onComplete方法here
的更多详细信息