Reputation: 75
how do I check if a function is in progress? I want it to repeat itself if it isn't already in progress.
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)
Upvotes: 0
Views: 68
Reputation: 14565
I haven't used corona, but this is a common javascript idiom and is typically the way you would do it there:
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)
You can find more details about the onComplete method here
Upvotes: 3