feat(menu): play "menu enter" sound when button action is triggered
This commit is contained in:
parent
ef798896c3
commit
eb7486f57c
1 changed files with 11 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package handlers
|
|||
|
||||
import (
|
||||
"tetris/assets"
|
||||
"tetris/engine/audio"
|
||||
"tetris/engine/render"
|
||||
"tetris/game"
|
||||
"tetris/game/state"
|
||||
|
|
@ -17,12 +18,19 @@ type MainMenu struct {
|
|||
list *layouts.ListBox
|
||||
}
|
||||
|
||||
func enterState(fsm state.Transitioner, state string) func() {
|
||||
return func() {
|
||||
audio.Play(assets.SFX_MENU_ENTER)
|
||||
fsm.Switch(state)
|
||||
}
|
||||
}
|
||||
|
||||
func NewMainMenu(fsm state.Transitioner) *MainMenu {
|
||||
return &MainMenu{
|
||||
list: layouts.NewListBox([]ui.InputWidget{
|
||||
widgets.NewButton("Start", 32, func() { fsm.Switch("gameplay") }),
|
||||
widgets.NewButton("Options", 32, func() { fsm.Switch("options") }),
|
||||
widgets.NewButton("Quit", 32, func() { fsm.Switch("quit") }),
|
||||
widgets.NewButton("Start", 32, enterState(fsm, "gameplay")),
|
||||
widgets.NewButton("Options", 32, enterState(fsm, "options")),
|
||||
widgets.NewButton("Quit", 32, enterState(fsm, "quit")),
|
||||
}).Spacing(10).
|
||||
OnSelect(uievents.MenuSelect),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue