Need help with sound [ FIXED ]

For questions about using Classic.

Post » Fri Sep 28, 2012 9:05 pm

Hi I'm new to this forum. I'm using Construct Classic and I have a problem with sounds.

I was trying to make a game with some complicated sound options but I failed. Then I thought, maybe I'm missing something, I should try it with a simplier way and I failed that too so now heres the simple one:

I inserted Mouse&Keyboard, XAudio2 on the layout. Then I wrote:

On key 1 pressed-> 1_XAudio2: Load file AppPath & "1.wav" to channel 1 (No loop)
                   2_XAudio2: Play channel 1

On key 2 pressed-> 1_XAudio2: Load file AppPath & "2.wav" to channel 2 (No loop)
                   2_ Play channel 2

on the event sheet. And yes I also added 1.wav and 2.wav to Sounds in the Project.

Now. If I added 2.wav last into Sounds, when I launch the game and press 2, it plays the sound but doesn't play 1.wav. If I added 1.wav last into Sounds and when I launch and press 1, it plays the sound but doesn't play 2.wav. Or maybe it's just a coincidence.

Basically, it plays just 1 of them and doesn't play the other.

I don't understand what the problem is and I don't think I was able to tell you my problem here properly :(. But what I want is:

I want multiple sounds. Example: When I press 1, a sound will play. When I press 2, another sound will play. When I press 3 another and so on...

Please help me I'm thinking about a big game and this is the one and only problem I have.

Thanks in advance.Lacrimosa2012-10-06 13:25:11
B
2
Posts: 8
Reputation: 266

Post » Sat Sep 29, 2012 1:22 am

You're mixing resources and files in the description. So I'm not sure, what you heading for.

Sound file play: You need to make sure that the files exist at AppPath & "xx.wav". AppPath always points to the directory, where the .cap or .exe exists. If you didn't save the .cap before running it, AppPath isn't valid.

Sound resource play: You need to add the sounds to the files folder in the project tab and have to use the "load resource" actions.

The two events you posted are quite a mess
You seem to have a xaudio object called "1_XAudio2" and load the file to it. But then you try to play it on an object called "2_XAudio2", which never had any files loaded to its channels.

Summary: Place all your sounds in the correct folder on disc. Use just one XAudio2 object. Correct the two events to only load and play on this one XAudio2 object. Save the cap before running.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Sep 29, 2012 5:53 am

Well actually those 1_ and 2_ were to show the number of actions :P my bad. I only used "XAudio2" not something else. And I also tried another things like, using a different audio thing for each sound like: XAudio1 will play 1.wav, XAudio2 will play 2.wav etc. but that didn't work too. Anyway I'll try what you're saying here and get back to you :D


EDIT1: WOW! Thanks a lot! This solves my problem.

Here's the fix for the people who couldn't figure out putting sounds like me :P

[QUOTE=tulamide] Sound resource play: You need to add the sounds to the files folder in the project tab and have to use the "load resource" actions.[/QUOTE]

Locking topic, thanks again.

EDIT2: Eh, how do I lock topic :D :S

Lacrimosa2012-09-29 06:05:35
B
2
Posts: 8
Reputation: 266


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests