ExperimentalGear/scripts/titlescreen/splash/creditspage.lua

64 lines
1.4 KiB
Lua

require "common.globals"
require "common.class"
local Display = require "scripts.graphics.display"
local Image = require "scripts.graphics.image"
local Page = require "api.page.page"
---@class CreditsPage : Page
---@field logo_img Image
---@field _timer number
local CreditsPage = {
__name = "CreditsPage",
BACKGROUND_COLOR = {255, 255, 255},
LOGO_PATH = "",
TIMEOUT = 3.0
}
---Create a new CreditsPage instance
---@param params? CreditsPage
function CreditsPage.new(params)
local self = CreateInstance(CreditsPage, params, Page)
self.logo_img = Image.new(self.LOGO_PATH)
self._timer = 0.0
return self
end
function CreditsPage:init()
self._timer = 0.0
Page.init(self)
end
function CreditsPage:drawBackground(deltaTime)
gfx.BeginPath()
gfx.FillColor(table.unpack(self.BACKGROUND_COLOR))
gfx.Rect(0, 0, Display.design.width, Display.design.height)
gfx.Fill()
end
function CreditsPage:drawContent(deltaTime)
local x = (Display.design.width - self.logo_img.width) / 2
local y = (Display.design.height - self.logo_img.height) / 2
self.logo_img:setPosition(x, y)
self.logo_img:render()
end
function CreditsPage:render(deltaTime)
Page.render(self, deltaTime)
if self._timer > self.TIMEOUT then
self:onInvalidation()
end
self._timer = self._timer + deltaTime
end
return CreditsPage