Playing sounds.

For questions about using Classic.

Post » Tue May 05, 2009 1:55 pm

I have several .wav files in my game that I wish to use.How do I load and play them ?Say a bullet fires and I want to play a sound e.g(bang.wav)
B
27
S
2
G
3
Posts: 61
Reputation: 2,498

Post » Tue May 05, 2009 2:01 pm

Use the XAudio2 object.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue May 05, 2009 2:21 pm

After adding the Xaudio2 object go to your event sheet.

Just for an example, make an "On any key pressed" and then under "New Action" select "Autoplay File". For the "AppPath" tell it where to look for the file (make sure it is in parenthesis) and replace "example.wav" with the name of your sound.

That loads the sound as you play it, though. So if it's a big file you might want to use the "Load File" instead. You use it the same but if you have a lot of big files and you don't want your game to lag you can make a "please wait...loading" screen that pops up after you choose to start your game. Use that screen to "Load File" your big sounds and *then* have your game start.

Be sure to make a note of which sound is loaded to which channel, though. (you play them by selecting "Play" and then telling it which channel you want.
B
4
S
2
G
4
Posts: 401
Reputation: 2,302

Post » Tue May 05, 2009 8:54 pm

There's a great tutorial for implementing simple sounds @ the wiki.
[url:3vdet0pb]http://apps.sourceforge.net/mediawiki/construct/index.php?title=Tutorials[/url:3vdet0pb]
B
2
G
3
Posts: 40
Reputation: 930


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest