feat: add transformation from list
This commit is contained in:
parent
f1b61c9db7
commit
dd0fcf2547
2 changed files with 25 additions and 0 deletions
|
@ -28,6 +28,7 @@ local ScreenList = require "birb.modules.gui.mixins.screens"
|
|||
Gui:implement(ScreenList)
|
||||
Gui:implement(ElementList)
|
||||
|
||||
local TransformDataStruct = require "birb.structures.tween"
|
||||
|
||||
function Gui:new(scene)
|
||||
self.scene = scene
|
||||
|
@ -50,6 +51,25 @@ end
|
|||
-- TWEEN FUNCTIONS
|
||||
-- Handle tweening
|
||||
|
||||
function Gui:transform(data)
|
||||
for _, rawTransform in ipairs(data) do
|
||||
self:transformOne(rawTransform)
|
||||
end
|
||||
end
|
||||
|
||||
function Gui:transformOne(rawTransform)
|
||||
local struct = TransformDataStruct[rawTransform[2]]
|
||||
assert(struct ~= nil, "Structure " .. rawTransform[1] .. " doesn't exists ")
|
||||
local transform = utils.table.parse(rawTransform, struct, 0)
|
||||
if transform.type == "tween" then
|
||||
self:newTween(transform.name, transform.start, transform.duration, transform.target, transform.easing)
|
||||
elseif transform.type == "movement" then
|
||||
self:newMovement(transform.name, transform.start, transform.duration, transform.x, transform.y, transform.easing)
|
||||
elseif transform.type == "switch" then
|
||||
self:newSwitch(transform.name, transform.start, transform.bools)
|
||||
end
|
||||
end
|
||||
|
||||
function Gui:newTween(element, start, duration, target, easing)
|
||||
self.elements[element]:newTween(start, duration, target, easing)
|
||||
end
|
||||
|
|
5
sonic-radiance.love/birb/structures/tween.lua
Normal file
5
sonic-radiance.love/birb/structures/tween.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
tween = {"name", "type", "start", "duration", "target", "easing"},
|
||||
movement = {"name", "type", "start", "duration", "x", "y", "easing"},
|
||||
switch = {"name", "type", "start", "bools"},
|
||||
}
|
Loading…
Reference in a new issue