1.协同程序的概念:
函数只运行一次,每一帧都要运行。
Update,每帧都会重新调用
2.协程的创建:
①coroutine.create
fun =function ()
print(123)
end
co=coroutine.create(fun)
print(type(co)) 输出thread
②corountine.wrap()
co2=coroutine.wrap(fun)
print(type(co)) 输出function
3.协程的运行:
通过使用create创建的协程:coroutine.resume(co)
每使用一次resume就接着上一次的运行继续运行
使用wrap创建的协程:co2()
4.协程的挂起:
fun2=functgion ()
local=1
while true do
print(i)
i=i+1