feature/simple_ui #18

Merged
PeaAshMeter merged 25 commits from feature/simple_ui into main 2025-11-08 01:32:47 +03:00
Showing only changes of commit 6a15c6ed83 - Show all commits

View File

@ -33,6 +33,7 @@ local easing = require "lib.utils.easing"
--- @field duration number продолжительность в миллисекундах
--- @field easing ease функция смягчения
--- @field t number прогресс анимации
--- @field finished boolean
local animation = {}
animation.__index = animation
@ -40,6 +41,7 @@ animation.__index = animation
function animation:bubbleUp()
self.count = self.count - 1
if self.count > 0 then return end
self.finished = true
if self.onEnd then self.onEnd() end
if self.parent then self.parent:bubbleUp() end
end
@ -61,6 +63,8 @@ function animation:getValue()
end
function animation:update(dt)
if self.finished then return end
if self.t < 1 then
self.t = self.t + dt * 1000 / self.duration -- в знаменателе продолжительность анимации в секундах
else
@ -78,12 +82,14 @@ local function new(data)
end
t.onEnd = data.onEnd
t.count = 1 -- своя анимация
t.finished = false
t.children = {}
t:chain(data.children or {})
t.duration = data.duration or 1000
t.easing = data.easing or easing.linear
t.t = 0
t.finish = function()
if t.finished then return end
t:bubbleUp()
for _, anim in ipairs(t.children) do
anim:run()