epervier-old/examples/scenes/gameplay/plateform/pause.lua

61 lines
1.5 KiB
Lua

local ListMenu = require "framework.scenes.gui.menus.listbox"
local Widget = require "framework.scenes.gui.menus.widgets"
local PauseMenu = ListMenu:extend()
local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend()
local MENU_NAME = "PauseMenu"
function PauseMenu:new(scene)
self.scene = scene
local screenHeight, screenWidth = core.screen:getDimensions()
local w, h = 424/4, 240 - 48*4
local x, y = 3*w/2, 24*4
PauseMenu.super.new(self, scene.menusystem, MENU_NAME, x, y, w, h, 3)
ResumeWidget()
RestartWidget()
ExitWidget()
end
-- WIDGETS
-- All widgets used by the pause menu
function ResumeWidget:new()
self.scene = core.scenemanager:getScene()
local label = "resume"
ResumeWidget.super.new(self, MENU_NAME, "medium", label)
end
function ResumeWidget:action()
self.scene.assets:playSFX(self.sfx)
self.scene.menusystem:deactivate()
end
function RestartWidget:new()
self.scene = core.scenemanager:getScene()
local label = "restart"
RestartWidget.super.new(self, MENU_NAME, "medium", label)
end
function RestartWidget:action()
self.scene.assets:playSFX(self.sfx)
self.scene:restart()
end
function ExitWidget:new()
self.scene = core.scenemanager:getScene()
local label = "exit"
ExitWidget.super.new(self, MENU_NAME, "medium", label)
end
function ExitWidget:action()
self.scene.assets:playSFX(self.sfx)
core.scenemanager:setStoredScene("mainmenu")
end
return PauseMenu