example/mainmenu : add an exit widget
This commit is contained in:
parent
a9fb455ec0
commit
00aedfd89b
1 changed files with 14 additions and 0 deletions
|
@ -29,6 +29,7 @@ local Widget = require "gamecore.modules.menusystem.widgets"
|
|||
|
||||
local SubMenuWidget = Widget.Text:extend()
|
||||
local SceneWidget = Widget.Text:extend()
|
||||
local ExitWidget = Widget.Text:extend()
|
||||
|
||||
function MainMenu:new()
|
||||
MainMenu.super.new(self)
|
||||
|
@ -42,6 +43,7 @@ function MainMenu:new()
|
|||
self:addSubMenu("menus", "Menus Tests")
|
||||
self:addScene("menus", examples.Inventory, "Inventory")
|
||||
|
||||
ExitWidget(self, "main")
|
||||
self.menusystem:switchMenu("main")
|
||||
end
|
||||
|
||||
|
@ -102,5 +104,17 @@ function SceneWidget:action()
|
|||
self.newscene()
|
||||
end
|
||||
|
||||
-- Exit Widget : exit the examples
|
||||
|
||||
function ExitWidget:new(scene, menu)
|
||||
self.scene = scene
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets.fonts["medium"]
|
||||
SceneWidget.super.new(self, widgetmenu, font, "Exit")
|
||||
end
|
||||
|
||||
function ExitWidget:action()
|
||||
love.event.quit()
|
||||
end
|
||||
|
||||
return MainMenu
|
||||
|
|
Loading…
Reference in a new issue