ExperimentalGear/scripts/titlescreen/splash/uscpage.lua

64 lines
1.3 KiB
Lua
Raw Normal View History

require "common.globals"
require "common.class"
2024-02-02 02:50:48 +01:00
local Display = require "scripts.graphics.display"
2023-08-19 04:48:46 +02:00
local Image = require "scripts.graphics.image"
local Page = require "api.page.page"
---@class USCPage : Page
---@field logo_img Image
---@field _timer number
local USCPage = {
__name = "USCPage",
BACKGROUND_COLOR = {255, 255, 255},
LOGO_PATH = "titlescreen/splash/usc2.png",
TIMEOUT = 3.0
}
---Create a new USCPage instance
---@param params? USCPage
function USCPage.new(params)
local self = CreateInstance(USCPage, params, Page)
self.logo_img = Image.new(self.LOGO_PATH)
self._timer = 0.0
return self
end
function USCPage:init()
self._timer = 0.0
Page.init(self)
end
function USCPage:drawBackground(deltaTime)
gfx.BeginPath()
gfx.FillColor(table.unpack(self.BACKGROUND_COLOR))
2024-02-02 02:50:48 +01:00
gfx.Rect(0, 0, Display.design.width, Display.design.height)
gfx.Fill()
end
function USCPage:drawContent(deltaTime)
2024-02-02 02:50:48 +01:00
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 USCPage:render(deltaTime)
Page.render(self, deltaTime)
if self._timer > self.TIMEOUT then
self:onInvalidation()
end
self._timer = self._timer + deltaTime
end
2023-08-19 04:48:46 +02:00
return USCPage