mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
add animation.action
This commit is contained in:
parent
c19733b594
commit
39a3c1201f
6 changed files with 45 additions and 13 deletions
|
|
@ -299,4 +299,27 @@ function __vc_internals.load_vca_animation(filepath, identifier)
|
|||
this.load_vca(filepath, identifier)
|
||||
end
|
||||
|
||||
local running_actions = {}
|
||||
|
||||
function this.action(func)
|
||||
table.insert(running_actions, coroutine.create(func))
|
||||
end
|
||||
|
||||
function __vc_internals.on_animation_frame()
|
||||
for i=#running_actions,1,-1 do
|
||||
local co = running_actions[i]
|
||||
local status, result = coroutine.resume(co)
|
||||
if not status then
|
||||
debug.error("error in animation action: "..result)
|
||||
table.remove(running_actions, i)
|
||||
elseif coroutine.status(co) == "dead" then
|
||||
table.remove(running_actions, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __vc_internals.stop_all_actions()
|
||||
running_actions = {}
|
||||
end
|
||||
|
||||
return this
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue