IrrKlang and/or time help [H E L P!]
-
- Posts: 98
- Joined: Fri Oct 03, 2008 1:25 pm
- Location: UK
- Contact:
IrrKlang and/or time help [H E L P!]
Hey guys,
I think the best way to ask my question is to explain what I want to do, well - what I want is to create an introduction to the client about who developed the game before going to the main menu - for instance, creating a static image with the company logo, playing a sound effect and then going to the main menu.
The way I tried to approach this was to render the image, play the required sound, and then test a condition to see if the sound is playing/finished is methods to as (ISoundSource) as a param etc, but it doesn't seem to work correctly, I've managed to use the IsCurrentlyPlaying functions correctly, and isFinished, it compiled fine and all arguments are correct, but only the first condition works in the correctly set up if/else conditional statements, I've tried a few ways to test if the engine is/is not playing a specified sound but to no avail, I have looked through the IrrKlang API documentation and it appears what I am doing is correct, and debugging confirms this - can someone shed some light on this and some code would be nice.
Lastly, I tried to think of a different approach, that was, to chech if a certain amount of seconds has passed, then to perform the required task - I also looked this up in the API doc's but could not find a definitive method to do this, thus, some help there would be nice too
I think the best way to ask my question is to explain what I want to do, well - what I want is to create an introduction to the client about who developed the game before going to the main menu - for instance, creating a static image with the company logo, playing a sound effect and then going to the main menu.
The way I tried to approach this was to render the image, play the required sound, and then test a condition to see if the sound is playing/finished is methods to as (ISoundSource) as a param etc, but it doesn't seem to work correctly, I've managed to use the IsCurrentlyPlaying functions correctly, and isFinished, it compiled fine and all arguments are correct, but only the first condition works in the correctly set up if/else conditional statements, I've tried a few ways to test if the engine is/is not playing a specified sound but to no avail, I have looked through the IrrKlang API documentation and it appears what I am doing is correct, and debugging confirms this - can someone shed some light on this and some code would be nice.
Lastly, I tried to think of a different approach, that was, to chech if a certain amount of seconds has passed, then to perform the required task - I also looked this up in the API doc's but could not find a definitive method to do this, thus, some help there would be nice too
Last edited by Systemerror on Wed Apr 22, 2009 9:11 am, edited 1 time in total.
-System error
-
- Posts: 98
- Joined: Fri Oct 03, 2008 1:25 pm
- Location: UK
- Contact:
-
- Posts: 98
- Joined: Fri Oct 03, 2008 1:25 pm
- Location: UK
- Contact:
hybrid wrote:You can use the Irrlicht timer to check the time already used. For irrKlang please ask in their forum (therefore also moving too game programming forum).
Ok, like a time elapsed function... can you give a code example, I can't look through the documentation until tommorow as I'm not on my box.
The example structure being:
if time passed (in milliseconds I imagine so 5 nano seconds is 5000 milliseconds I believe)
//do something/show logo
else
//do something else
-System error
1 nano second is 0.000001 milliseconds.Systemerror wrote:5 nano seconds is 5000 milliseconds I believe
See http://en.wikipedia.org/wiki/SI_prefix
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
-
- Posts: 98
- Joined: Fri Oct 03, 2008 1:25 pm
- Location: UK
- Contact:
Sylence wrote:1 nano second is 0.000001 milliseconds.Systemerror wrote:5 nano seconds is 5000 milliseconds I believe
See http://en.wikipedia.org/wiki/SI_prefix
Yeah it's 1 "standard second" to 1,000 "milliseconds", I don't know why I said nano second.
um...
ITimer *timer = device->getTimer();
u32 startTime = timer->getTime();
while (timer->getTime() - startTime < 5000) // wait 5 seconds
{
logoRenderUpdate();
}
//continue
Great that cheers, I couldn't get to the API docs
-System error
-
- Posts: 98
- Joined: Fri Oct 03, 2008 1:25 pm
- Location: UK
- Contact:
Have a look at irrklang::ISoundStopEventReceiver. In the section of code that checks if the sound is done playing, you can check a flag that is set by the event handler:
Code: Select all
bool sndIsDone=false;
irrklang::ISound* snd;
class MySoundEndReceiver : public irrklang::ISoundStopEventReceiver
{
public:
virtual void OnSoundStopped (irrklang::ISound* sound, irrklang::E_STOP_EVENT_CAUSE reason, void* userData)
{
// called when the sound has ended playing
if(userData == snd)
{
sndIsDone = true;
printf("sound has ended");
}
}
}
// ...
MySoundEndReceiver* myReceiver = new MySoundEndReceiver();
snd = engine->play2D("speech.mp3", false, false, true);
if (snd)
snd->setSoundStopEventReceiver(myReceiver, snd);
// render loop
while(Device->run())
{
if(sndIsDone)
{
// proceed to menu state
}
}
im working on a dialog type
im doing a type of dialog playing sounds in times that i want if you are interested i can tell you more just tell me if you are interested