Refonte pour utiliser le systeme de GUI #112
2 changed files with 36 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
local Rect = require "birb.classes.2D.rect"
|
local Rect = require "birb.classes.2D.rect"
|
||||||
local GuiElement = Rect:extend()
|
local GuiElement = Rect:extend()
|
||||||
|
|
||||||
|
local TweenManager = require "birb.classes.time"
|
||||||
|
|
||||||
function GuiElement:new(name, x, y, w, h)
|
function GuiElement:new(name, x, y, w, h)
|
||||||
GuiElement.super.new(self, x, y, w, h)
|
GuiElement.super.new(self, x, y, w, h)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -10,6 +12,8 @@ function GuiElement:new(name, x, y, w, h)
|
||||||
|
|
||||||
self.depth = 0
|
self.depth = 0
|
||||||
|
|
||||||
|
self.tweens = TweenManager(self)
|
||||||
|
|
||||||
self:register()
|
self:register()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,6 +77,7 @@ end
|
||||||
-- External update function
|
-- External update function
|
||||||
function GuiElement:updateElement(dt)
|
function GuiElement:updateElement(dt)
|
||||||
self:update(dt)
|
self:update(dt)
|
||||||
|
self.tweens:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Internal update function
|
-- Internal update function
|
||||||
|
@ -80,6 +85,21 @@ function GuiElement:update(dt)
|
||||||
-- Cette fonction ne contient rien par défaut
|
-- Cette fonction ne contient rien par défaut
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TWEEN FUNCTIONS
|
||||||
|
-- Handle tweening
|
||||||
|
|
||||||
|
function GuiElement:newTween(start, duration, target, easing)
|
||||||
|
self.tweens:newTween(start, duration, target, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GuiElement:newMovement(start, duration, x, y, easing)
|
||||||
|
self:newTween(start, duration, {x = x, y = y}, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GuiElement:newSwitch(start, bools)
|
||||||
|
self:newSwitch(start, bools)
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Draw the menu and its content
|
-- Draw the menu and its content
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,28 @@ function Gui:reset()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui:update(dt)
|
function Gui:update(dt)
|
||||||
for _, element in ipairs(self.elements) do
|
for _, element in pairs(self.elements) do
|
||||||
if (element ~= nil) then
|
if (element ~= nil) then
|
||||||
element:updateElement(dt)
|
element:updateElement(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TWEEN FUNCTIONS
|
||||||
|
-- Handle tweening
|
||||||
|
|
||||||
|
function Gui:newTween(element, start, duration, target, easing)
|
||||||
|
self.elements[element]:newTween(start, duration, target, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gui:newMovement(element, start, duration, x, y, easing)
|
||||||
|
self.elements[element]:newMovement(start, duration, x, y, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gui:newSwitch(element, start, bools)
|
||||||
|
self.elements[element]:newSwitch(start, bools)
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Draw the menu and its content
|
-- Draw the menu and its content
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue