Play Sound

For questions about using Classic.

Post » Tue Apr 26, 2011 6:21 pm

Okay, so im making a breakout game, but i encountered a problem during my time adding sounds effects. When my ball hits the bricks i want to play a break sound.

So far i've done:

Event: Start of layout - XAudio2: Load file AppPath & "Break.wav" to channel 1 (No loop)
Event: On collision between Ball and Brick1 - XAudio2: Play Channel 1

The problem is that the sound only plays when i hit the first brick, how do i make it play the sound every time i destroy a brick?
B
2
G
1
Posts: 16
Reputation: 507

Post » Tue Apr 26, 2011 8:35 pm

Is there anyone that can help me with this issue tonight, i need help as quick as possible.
B
2
G
1
Posts: 16
Reputation: 507

Post » Tue Apr 26, 2011 8:42 pm

You should use the autoplay file action. Alternatively, put your load file action into the event where the ball hits the brick.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Apr 26, 2011 8:45 pm

Or you put after the "play channel 1" command, "channel set position to 0.
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Tue Apr 26, 2011 9:20 pm

Re Playing sound

+ On collision between Ball and Brick
+ System: Trigger once
-> XAudio2: Autoplay file AppPath & "sounds\Smash.ogg" (No loop)
B
19
S
6
G
7
Posts: 1,205
Reputation: 7,298

Post » Tue Apr 26, 2011 10:24 pm

What if I want to play it on a specific channel?
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Tue Apr 26, 2011 11:14 pm

A sound channel does not reset its position automatically. You have to stop it playing and reset its position manually. So do what zyblade wrote with the change that you set the position to zero prior to playing the channel.

+ On collision between Ball and Brick
-> XAudio2: Set Channel 1 Position to 0 seconds
-> XAudio2: Play Channel 1

Edit: I'm sorry, you also have to add this line to your event sheet:
+ XAudio2: [negated] Channel 1 is playing
-> XAudio2: Stop channel 1
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests