improvement: let the screen handle opacity

This commit is contained in:
Kazhnuz 2021-08-31 10:56:43 +02:00
parent da9dbb30b8
commit 36b4d16939
7 changed files with 10 additions and 12 deletions

View file

@ -1,12 +1,12 @@
local Parent = require "birb.modules.gui.elements.drawable"
local AssetElement = Parent:extend()
function AssetElement:new(name, assetType, assetName, x, y,r,sx,sy,ox,oy, opacity, depth)
function AssetElement:new(name, assetType, assetName, x, y,r,sx,sy,ox,oy, opacity)
local gui = self:getGui()
local asset = gui.scene.assets[assetType][assetName]
assert(asset ~= nil, assetName .. ' (' .. assetType .. ") doesn't exist")
AssetElement.super.new(self, name, asset, x, y,r,sx,sy,ox,oy, opacity, depth)
AssetElement.super.new(self, name, asset, x, y,r,sx,sy,ox,oy, opacity)
end
function AssetElement:draw()

View file

@ -1,14 +1,13 @@
local Parent = require "birb.modules.gui.elements.parent"
local CanvasElement = Parent:extend()
function CanvasElement:new(name, x, y, w, h, r,sx,sy,ox,oy, opacity, depth)
function CanvasElement:new(name, x, y, w, h, r,sx,sy,ox,oy, opacity)
self:initCanvas()
CanvasElement.super.new(self, name, x, y, w, h)
self.r = r or 0
self.sx, self.sy = sx or 1, sy or 1
self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h)
self.opacity = opacity or 1
self.depth = depth or 0
end
function CanvasElement:initCanvas()

View file

@ -28,6 +28,7 @@ function CompositeElement:update(dt)
childElement.x = self.x + child.relx
childElement.y = self.y + child.rely
childElement.isVisible = self.isVisible
childElement.depth = self.depth
end
end

View file

@ -1,8 +1,8 @@
local Parent = require "birb.modules.gui.elements.variable"
local CounterElement = Parent:extend()
function CounterElement:new(name, fontName, object, varName, nbrs, x, y, align, depth)
CounterElement.super.new(self, name, fontName, object, varName, x, y, align, depth)
function CounterElement:new(name, fontName, object, varName, nbrs, x, y, align)
CounterElement.super.new(self, name, fontName, object, varName, x, y, align)
self.nbrs = nbrs or 0
end

View file

@ -1,7 +1,7 @@
local Parent = require "birb.modules.gui.elements.parent"
local DrawableElement = Parent:extend()
function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity, depth)
function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity)
self.drawable = drawable
local w, h = self.drawable:getDimensions()
@ -10,7 +10,6 @@ function DrawableElement:new(name, drawable, x, y,r,sx,sy,ox,oy, opacity, depth)
self.sx, self.sy = sx or 1, sy or 1
self.ox, self.oy = self:parseOrigin(ox, w), self:parseOrigin(oy, h)
self.opacity = opacity or 1
self.depth = depth or 0
end
function DrawableElement:parseOrigin(origin, size)

View file

@ -1,14 +1,13 @@
local Parent = require "birb.modules.gui.elements.parent"
local TextElement = Parent:extend()
function TextElement:new(name, fontName, text, x, y, align, depth)
function TextElement:new(name, fontName, text, x, y, align)
self.text = text
local gui = self:getGui()
self.font = gui.scene.assets.fonts[fontName]
TextElement.super.new(self, name, x, y, 1, 1)
self.align = align
self.depth = depth or 0
end
function TextElement:getText()

View file

@ -1,8 +1,8 @@
local Parent = require "birb.modules.gui.elements.text"
local VariableElement = Parent:extend()
function VariableElement:new(name, fontName, object, varName, x, y, align, depth)
VariableElement.super.new(self, name, fontName, "", x, y, align, depth)
function VariableElement:new(name, fontName, object, varName, x, y, align)
VariableElement.super.new(self, name, fontName, "", x, y, align)
self.object = object
self.variable = varName
end