mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-28 01:29:31 +00:00
Add callback, children, timer example systems
This commit is contained in:
parent
6ee98c097f
commit
9f4c03a136
3 changed files with 119 additions and 0 deletions
35
ecs/timer.can
Normal file
35
ecs/timer.can
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
--- Timer system
|
||||
-- Handles ubiquitousse timers.
|
||||
|
||||
let timer = require((...):match("^(.-)ecs%.timer").."scene")
|
||||
|
||||
return {
|
||||
name = "timer",
|
||||
filter = "timer",
|
||||
default = {
|
||||
-- timer object
|
||||
},
|
||||
process = :(t, dt)
|
||||
t:update(dt)
|
||||
if t:dead() then
|
||||
@world:remove(t.entity)
|
||||
end
|
||||
end,
|
||||
--- System methods ---
|
||||
--- Add a new timer
|
||||
run = :(func)
|
||||
local t = timer.run(func)
|
||||
@world:add {
|
||||
timer = t
|
||||
}
|
||||
return t
|
||||
end,
|
||||
--- Add a new tween
|
||||
tween = :(duration, tbl, to, method)
|
||||
local t = timer.tween(duration, tbl, to, method)
|
||||
@world:add {
|
||||
timer = t
|
||||
}
|
||||
return t
|
||||
end
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue