ArBuZ Posted April 11, 2010 Share Posted April 11, 2010 Hi! I want to implement an option Sound and Music volume in my game. And Ive found that its not as simple as it should be There is no any global parameter in the engine, only SetSourceVolume. But then I have to go through all my sources and set it's volume. Have anyone done this before? Thanks in advance. Quote Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64 3ds max / photoshop CS3 / C++ http://www.arbuznikov.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 11, 2010 Share Posted April 11, 2010 I would try something like the following. First make groups of sounds and sound sources. --load sound music1 = LoadSound("abstract::music1.OGG") music2 = LoadSound("abstract::music2.OGG") sound1 = LoadSound("abstract::sound1.OGG") sound2 = LoadSound("abstract::sound2.OGG") -- create sources source_music1 =CreateSource (music1) source_music2 =CreateSource (music2) source_sound1 =CreateSource (sound1) source_sound2 =CreateSource (sound2) --declare 2 sound variables MusicVolume = 5 SoundVolume = 5 -- 2 functions for setting the volume function SetVolumeOfMusic () source_music1:SetVolume( MusicVolume ) source_music2:SetVolume( MusicVolume ) end function SetVolumeOfSound () source_Sound1:SetVolume( SoundVolume ) source_Sound2:SetVolume( SoundVolume ) end It would be even better if you could add a source to a Sound group. This way you wouldn't even have to place all sources in to the function. Quote Link to comment Share on other sites More sharing options...
ArBuZ Posted April 11, 2010 Author Share Posted April 11, 2010 Your way would work for simple solutions. But in complex solutions with classes (C++) when for example Source is a member of class, things become more complicated and handling all sources of all objects in scene is very tricky. Quote Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64 3ds max / photoshop CS3 / C++ http://www.arbuznikov.com Link to comment Share on other sites More sharing options...
MrIslomaniac Posted April 11, 2010 Share Posted April 11, 2010 Hey arbuz, you could write the lights into an array and then loop throught all of them. You can also use EmitSound if you want, because there you can set the volume directly =) Hope it'll help you Dustin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.