example/mainmenu: add confirm and cancel sfx
This commit is contained in:
parent
fe740edc13
commit
5c8452b226
1 changed files with 6 additions and 1 deletions
|
@ -35,7 +35,9 @@ function MainMenu:new()
|
||||||
MainMenu.super.new(self)
|
MainMenu.super.new(self)
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue