ExperimentalGear/scripts/titlescreen/splash/teamexceedpage.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 TeamExceedPage : Page
---@field logo_img Image
---@field _timer number
local TeamExceedPage = {
__name = "TeamExceedPage",
BACKGROUND_COLOR = {255, 255, 255},
LOGO_PATH = "titlescreen/splash/team-exceed.png",
TIMEOUT = 3.0
}
---Create a new TeamExceedPage instance
---@param params? TeamExceedPage
function TeamExceedPage.new(params)
local self = CreateInstance(TeamExceedPage, params, Page)
self.logo_img = Image.new(self.LOGO_PATH)
self._timer = 0.0
return self
end
function TeamExceedPage:init()
self._timer = 0.0
Page.init(self)
end
function TeamExceedPage: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 TeamExceedPage: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 TeamExceedPage:render(deltaTime)
Page.render(self, deltaTime)
if self._timer > self.TIMEOUT then
self:onInvalidation()
end
self._timer = self._timer + deltaTime
end
return TeamExceedPage