2021-08-22 16:45:43 +02:00
|
|
|
local Parent = require "birb.modules.gui.elements.parent"
|
|
|
|
local TextElement = Parent:extend()
|
|
|
|
|
2021-08-31 10:56:43 +02:00
|
|
|
function TextElement:new(name, fontName, text, x, y, align)
|
2021-08-31 23:47:01 +02:00
|
|
|
TextElement.super.new(self, name, x, y, 1, 1)
|
2021-08-22 16:45:43 +02:00
|
|
|
self.text = text
|
2021-08-31 23:47:01 +02:00
|
|
|
self.font = self.assets.fonts[fontName]
|
2021-08-22 16:45:43 +02:00
|
|
|
|
|
|
|
self.align = align
|
2021-09-03 11:13:06 +02:00
|
|
|
self.opacity = 1
|
2021-08-22 16:45:43 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function TextElement:getText()
|
|
|
|
return self.text
|
|
|
|
end
|
|
|
|
|
|
|
|
function TextElement:draw()
|
2021-09-03 11:13:06 +02:00
|
|
|
self.font:setColor(1, 1, 1, self.opacity)
|
2021-08-22 16:45:43 +02:00
|
|
|
self.font:draw(self:getText(), self.x, self.y, -1, self.align)
|
2021-09-03 11:13:06 +02:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
2021-08-22 16:45:43 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return TextElement
|