2022-01-06 18:57:42 +01:00
|
|
|
local PauseScreen = require("birb.modules.gui.screen"):extend()
|
2020-08-16 10:52:00 +02:00
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
local BoxedMenu = require("game.modules.gui.boxedmenu")
|
|
|
|
local TextElement = require("birb.modules.gui.elements.text")
|
2020-08-16 10:52:00 +02:00
|
|
|
|
2020-08-20 10:17:46 +02:00
|
|
|
local WIDTH = 80
|
2022-01-06 18:57:42 +01:00
|
|
|
local X, Y, TXT_Y = 424/2, 240/2, 240/6
|
|
|
|
local OX, OY = WIDTH/2, (3*17)/2
|
|
|
|
|
|
|
|
local show = {
|
|
|
|
{"pauseMenu", "tween", 0.1, 0.3, {opacity = 1, sx = 1, sy = 1}, "inOutQuart"},
|
|
|
|
{"pauseText", "tween", 0.1, 0.3, {opacity = 1, y = TXT_Y}, "inOutQuart"},
|
|
|
|
}
|
|
|
|
|
|
|
|
local hide = {
|
|
|
|
{"pauseMenu", "tween", 0, 0.3, {opacity = 0, sx = 0.8, sy = 0.8}, "inOutQuart"},
|
|
|
|
{"pauseText", "tween", 0, 0.3, {opacity = 0, y = TXT_Y - 16}, "inOutQuart"},
|
|
|
|
}
|
|
|
|
|
|
|
|
function PauseScreen:new()
|
|
|
|
PauseScreen.super.new(self, "pauseScreen")
|
|
|
|
self:addTransform("show", show)
|
|
|
|
self:addTransform("hide", hide)
|
|
|
|
self.defaultFocus = "pauseMenu"
|
2020-08-16 10:52:00 +02:00
|
|
|
end
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
function PauseScreen:createElements()
|
|
|
|
local pauseMenu = BoxedMenu("pauseMenu", X, Y, WIDTH, 3, true, false)
|
|
|
|
pauseMenu:addItem("Resume", "left", function() self.scene:unpause() end, "back")
|
|
|
|
pauseMenu:setCancelWidget()
|
|
|
|
pauseMenu:addItem("Restart", "left", function() self.scene:restartLevel() end, "back")
|
|
|
|
pauseMenu:addItem("Exit", "left", function() self.scene:exitLevel() end, "back")
|
|
|
|
pauseMenu.opacity = 0
|
|
|
|
pauseMenu.sx, pauseMenu.sy = 0.8, 0.8
|
|
|
|
pauseMenu.ox, pauseMenu.oy = OX, OY
|
|
|
|
|
|
|
|
local text = TextElement("pauseText", "SA2font", "Pause", X, TXT_Y - 16, "center")
|
|
|
|
text.opacity = 0
|
|
|
|
return {
|
|
|
|
{pauseMenu, 0, 1},
|
|
|
|
{text, 0, 1}
|
|
|
|
}
|
2020-08-16 10:52:00 +02:00
|
|
|
end
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
return PauseScreen
|