sonic-bluestreak/sonic-bluestreak.love/game/modules/subgames/pause.lua

64 lines
1.5 KiB
Lua
Raw Permalink Normal View History

local RadianceListMenu = require "game.modules.menus.list"
local PauseMenu = RadianceListMenu.ListMenu:extend()
local ResumeWidget = RadianceListMenu.DualTextWidget:extend()
local RestartWidget = RadianceListMenu.DualTextWidget:extend()
local ExitWidget = RadianceListMenu.DualTextWidget:extend()
local WIDTH = 80
function PauseMenu:new(subgame)
local x, y
x = 424/2 - WIDTH/2
y = 240/2 - (3*17)/2
PauseMenu.super.new(self, subgame, "pauseMenu", x, y, WIDTH, 3, true)
self:setSound(self.scene.assets.sfx["navigate"])
self.isActive = false
self.isVisible = false
ResumeWidget(subgame)
self:setCancelWidget()
RestartWidget(subgame)
ExitWidget(subgame)
end
--- MENU WIDGETS
function ResumeWidget:new(scene)
ResumeWidget.super.new(self, scene, "pauseMenu", "Resume", "")
end
function ResumeWidget:action()
self.menu.isActive = false
self.menu.isVisible = false
self.scene.world.isActive = true
self.scene.assets.isActive = true
self.scene:flushKeys()
end
function RestartWidget:new(scene)
ResumeWidget.super.new(self, scene, "pauseMenu", "Restart", "")
end
function RestartWidget:action()
self.scene:restartLevel()
self.menu.isActive = false
self.menu.isVisible = false
self.scene.world.isActive = true
self.scene.assets.isActive = true
self.scene:flushKeys()
end
function ExitWidget:new(scene)
ExitWidget.super.new(self, scene, "pauseMenu", "Exit", "")
end
function ExitWidget:action()
self.scene:exitLevel()
end
return PauseMenu