In this script:
function moveB()
if B then
B.x = B.x + 4
end
end
function clickA()
A.isVisible = false
B.isVisible = true
if fastSquare then
B.x, B.y = A.x, A.y
timer.performWithDelay(20, moveB, 5)
A.isVisible = true
B.isVisible = false
end
end
A:addEventListener("tap", clickA)
, I want this code:
A.isVisible = true
B.isVisible = false
to run after timer.performWithDelay()
has call function moveB() 5 times but they run the same time even if i have put A.isVisible = false B.isVisible = true
below timer.performWithDelay()
.
timer.performWithDelay(20, moveB, 5)
Says: after 20ms call moveB, do this 5 times in total.
As this is just registering the timed call of moveB anything that comes after that line is executed immediately.
As you already set those properties befor the if statement there is no need to do it inside the if statement again. It has no effect.
A.isVisible = false
B.isVisible = true
if fastSquare then
B.x, B.y = A.x, A.y
timer.performWithDelay(20, moveB, 5)
A.isVisible = false -- obsolete
B.isVisible = true -- obsolete
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.