epervier-framework/examples/scenes/gameplay/plateform/pause.lua
Kazhnuz 4b088dac87 improvement(assets): global asset system
Remove the old scene-bound asset system and replace it with a global one. Can lazyload but doesn't do it for the moment.

Fixes #70
!BREAKING
2024-10-28 17:19:29 +01:00

60 lines
1.4 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()
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()
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()
assets:playSFX(self.sfx)
core.scenemanager:setStoredScene("mainmenu")
end
return PauseMenu