如何检查功能是否在 corona sdk 中进行
How to check if a function is in progress in corona sdk
如何检查功能是否在进行中?如果它还没有进行,我希望它自己重复。
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)
我没有用过 corona,但这是一个常见的 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
如何检查功能是否在进行中?如果它还没有进行,我希望它自己重复。
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)
我没有用过 corona,但这是一个常见的 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