Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Play 2D sound with specific volume

spgardebiter
Registered User
Quote
2013-06-01 15:19:08

Hello,

I'm working on a 2D game and I want to implement sound playback in a way, that the volume of the sound depends on the distance of the object that emits the sound. So setting a volume for a sound effect is no actual option for me, as multiple instances of the sound could be played all with different volumes. I'm not looking for 3D playback as well, as this makes it way more complicated than it actually is.

Is there no way to play a sound with a specific volume? I know that I can create a pointer to an ISound object for every sound that I play, however then I would have to check every frame if the sound is still playing (not that this is a big issue but I want to be as efficient as possible).

So what is the best way of doing this? I hope you guys can help me out. ;)

Thanks,
S. P. Gardebiter


niko
Moderator
Quote
2013-06-02 07:31:10

I think the simplest way is to simply use play3D, and just ignore the z coordinate. Simply set you 2D coordinates into x and y, and set z to 0, always.
For setting the volume of a specific sound, you need to use the ISound interface.Checking if it is still playing isn't complicated either, just use isFinished(). :)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact