It looks like you're new here. If you want to get involved, click one of these buttons!
local function printHelloAndYieldFor2() print("Hello") Timer.delayedCall(2000, function() coroutine.resume(coFunc) end) coroutine.yield() end coFunc=coroutine.create( function() for i=1, 6 do printHelloAndYieldFor2() end end) coroutine.resume(coFunc) |
Comments
If you change the line
As you know resume runs in protected mode. Therefore, if there is any error inside a coroutine, Lua will not show the error message, but instead will return it to the resume call.
The solution is resuming the your coroutine inside another coroutine
Once I wrote a simple wait function with Timer.delayedCall and coroutines, hope it helps:
I guess that ENTER_FRAME events are handled on another (coroutine) thread then, because resuming inside an ENTER_FRAME handler does seems to work okay.
best regards
This is what I've been doing to work around the problem. Do you remember that postToUpdateQueue() function I mentioned some time ago. Well, I implemented it using a dummy GTween with a completion function. IIRC, GTween uses ENTER_FRAME events to dispatch its completion functions.
best regards
I'm having difficulty isolating a simple test case but if it helps, here is my wait code and a stack trace in Xcode after the crash.