Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Playing a sound once in a loop

george7378
Guest
Quote
2013-05-10 11:58:47

Hi there,

I'm using irrKlang in my 3D game, which of course uses a loop to render frames, update physics, etc... and I am having a little problem. Let's say I want to play a sound when a certain event happens, i.e. when a certain location is passed or a certain object is used. If I just call play2D() when the event happens, then every frame, the sound will be played from the beginning again as long as the condition is satisfied, resulting in a constant loop of the sound being played freshly every frame.
So my question is: How can I play a sound in irrKlang once and once only in this situation? i.e. only play it the first time the game detects that the condition is satisfied, rather than every time?

Thanks, I hope that was clear!


niko
Moderator
Quote
2013-05-10 13:51:22

Hm, not sure if I understand your problem correctly. But what is keeping you from doing something like this?

if (!soundPlayed)
{
irrKlang->play2D(yourSound);
soundPlayed = true;
}



george7378
Guest
Quote
2013-05-14 15:17:25

Hi, I tried that already, and I was wondering if there was another way of doing it because that requires that a bool is stored for each sound in the game, which gets a bit tedious! It would be nicer if there's a way of doing it using irrKlang functions only?


niko
Moderator
Quote
2013-05-15 05:48:50

Hm, why don't you just play the sound when the even happens, and not every frame? Playing sounds when you want them to be played is entirely your job, how should irrklang know when this should happen?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (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