Advertisement
Guest User

Как работает asyncCall

a guest
Mar 29th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. --Как работает asyncCall:
  2. function testFunc()
  3.     for i=1,100 do
  4.     Core.yield(true) --ставит цикл на паузу, в след.фрейме приступит к след.итерации
  5.     end
  6.     print "прошло 100 фреймов" --цикл исполнялся 100 фреймов
  7. end
  8. Core.asyncCall(testFunc) --вызываем функцию testFunc, через 100 фреймов напечатает "прошло 100 фреймов"
  9.  
  10. function testFunc2(ourSprite)
  11.     for i=1,100 do
  12.     ourSprite:setX(ourSprite:getX()+1)
  13.     Core.yield(true)
  14.     end
  15. end
  16. Core.asyncCall(testFunc2, ourPlayerSprite) --вызываем testFunc2 с передачей аргумента, в течение 100 фреймов будет смещать ourPlayerSprite на 1px вправо
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement