example/mainmenu: add confirm and cancel sfx

This commit is contained in:
Kazhnuz 2019-04-20 18:03:34 +02:00
parent fe740edc13
commit 5c8452b226

View file

@ -36,6 +36,8 @@ function MainMenu:new()
self.assets:addImageFont("medium", "examples/mainmenu/assets/medium") self.assets:addImageFont("medium", "examples/mainmenu/assets/medium")
self.assets:addSFX("navigate", "examples/mainmenu/assets/menu_move.mp3") self.assets:addSFX("navigate", "examples/mainmenu/assets/menu_move.mp3")
self.assets:addSFX("confirm", "examples/mainmenu/assets/menu_confirm.mp3")
self.assets:addSFX("cancel", "examples/mainmenu/assets/menu_error.mp3")
self:addMenu("main", true) self:addMenu("main", true)
self:addSubMenu("basic", "basic") self:addSubMenu("basic", "basic")
@ -93,14 +95,17 @@ function SubMenuWidget:new(scene, menu, newmenu, fullname, order)
local label = "" local label = ""
if fullname == "back" then if fullname == "back" then
label = core.lang:translate("commons", fullname) label = core.lang:translate("commons", fullname)
self.sfx = "cancel"
else else
label = core.lang:translate("mainmenu", fullname) label = core.lang:translate("mainmenu", fullname)
self.sfx = "confirm"
end end
SubMenuWidget.super.new(self, widgetmenu, font, label) SubMenuWidget.super.new(self, widgetmenu, font, label)
self.order = order or 0 self.order = order or 0
end end
function SubMenuWidget:action() function SubMenuWidget:action()
self.scene.assets:playSFX(self.sfx)
self.scene.menusystem:switchMenu(self.newmenu) self.scene.menusystem:switchMenu(self.newmenu)
end end