From 00aedfd89b2fa7ddc6dc42c9cae23c558623a741 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 7 Apr 2019 13:02:39 +0200 Subject: [PATCH] example/mainmenu : add an exit widget --- examples/mainmenu/init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/mainmenu/init.lua b/examples/mainmenu/init.lua index 7e0f8fc..fe2a84e 100644 --- a/examples/mainmenu/init.lua +++ b/examples/mainmenu/init.lua @@ -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