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

@ -35,7 +35,9 @@ function MainMenu:new()
MainMenu.super.new(self)
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:addSubMenu("basic", "basic")
@ -93,14 +95,17 @@ function SubMenuWidget:new(scene, menu, newmenu, fullname, order)
local label = ""
if fullname == "back" then
label = core.lang:translate("commons", fullname)
self.sfx = "cancel"
else
label = core.lang:translate("mainmenu", fullname)
self.sfx = "confirm"
end
SubMenuWidget.super.new(self, widgetmenu, font, label)
self.order = order or 0
end
function SubMenuWidget:action()
self.scene.assets:playSFX(self.sfx)
self.scene.menusystem:switchMenu(self.newmenu)
end