Are there any difference to a Coroutine and a function?
Here is my Code:
-- Coroutine local function doCoroutining() -- this has been called in scene:create local function mover() while ismOving do print("IS MOVING") coroutine.yield() end end moveMe = coroutine.create(mover) end -- Function local function doFfunction() print("IN FUNCTION") end -- onKeyEvent Runtime is created in "did show scene" local function onKeyEvent( event ) -- Print which key was pressed down/up local message = "Key '" .. event.keyName .. "' was pressed " .. event.phase print( message ) coroutine.resume(moveMe) doFfunction() return false end
there are no errors here, it’s just, they do the same, what’s the difference? Why should I use a Coroutine vs a Function?