Game Development Community

HOW TO PLAY A MANY WAV FILES WITH A SINGLE BUTTON

by karthikeyanK · in Torque Developer Network · 07/15/2009 (4:53 am) · 2 replies

In My project i have to play wav files. i am playing there is no problem. but my project is

I have 5 sections. In this when the user goes for the first section the song 1 should play ...

when he user goes for second sections.. the song2 should play......like that 5 different songs should

play......BUT WITH THE SINGLE BUTTON........i can't put many buttons...........

when the user enters the section the button should be populated automatically and when the user clicks

the button then the particular section song should play...

how to that.. how can i identify the sections and then how can i play the particular song for the particular section......

here i have a code for play the wav files....


%isPlaying = alxIsPlaying($AudioTestHandleA);
if(%isPlaying==0)
{
$AudioTestHandleA = alxCreateSource("AudioIntroMusicProfile",expandFilename("data/sound/crowd.wav"));
alxSetChannelVolume( 0 ,2 );
alxPlay($AudioTestHandleA);
}
else if(%isPlaying==1)
{
alxStop($AudioTestHandleA);
}


my problem is i have to play the five different wav files in a single button..................


please provide a solution



#1
07/15/2009 (10:22 am)
Do a test for area. Probably a trigger would work. Each "area" would have a sound datablock associated with it. Send the relevant sound datablock (AudioDescription) name as a parameter of whatever function you use to push the button to the screen. That way when you click the button it executes a command for alxPlay with the name of the sound you wish to be played.
#2
07/15/2009 (11:38 pm)
How to pass the trigger name to that button.. I dont know.. could you please give me the code...