So i have class menu, that organizes things like buttons, lists, boards etc.
sf::Sound Button_Click;
I'm loading sounds with this:
void Menu::Create_Buttons((...), sf::SoundBuffer &Snd_Over, sf::SoundBuffer &Snd_Click)
{
for(unsigned int i = 0; i < Number buttons(); i++)
{
sf_gui::Button New_Window;
[...]
New_Window.Button_Over.SetBuffer(Snd_Over);
New_Window.Button_Click.SetBuffer(Snd_Click);
Windows.insert(Windows.end(), New_Window);
}
}
And menu have method thad moves touch all buttons and playing sound if necessary:
if clicked on button
{
if(Clicked == true)
{
if(Is_Click_Played == false)
{
Button_Click.Play();
Is_Click_Played = true;
}
State = 2;
Result = true;
}
}
else Is_Click_Played = false;