Music Overlay Problems

Blitz3D Forums/Blitz3D Beginners Area/Music Overlay Problems

mintybreath(Posted 2007) [#1]
I made it so there is a button, that when pressed makes the sound play. When i tried to test it, i pressed the button. Instead of playing it once, it played it, what sounded like 20 times, overlayed into one. here is the code i used. Maybe there is some problem i did not notice in here. I cant seem to figure it out.

raesound=LoadSound("raegetton practice.wav")

while not keydown(1)

If MouseHit(1)
	whatwaspicked=CameraPick(camera,MouseX(),MouseY())
EndIf 


If whatwaspicked=raegetton Then
	raechan=PlaySound(raesound)
EndIf



Yahfree(Posted 2007) [#2]
it looks like because your storing 'whatwaspicked' then the condition is to see if 'whatwaspicked' equals raegetton, and if you store it, it always equals raegetton, thus playing the sound every loop..

try this:

raesound=LoadSound("raegetton practice.wav")

while not keydown(1)

If MouseHit(1)
	whatwaspicked=CameraPick(camera,MouseX(),MouseY())
EndIf 


If whatwaspicked=raegetton Then
	raechan=PlaySound(raesound)
                   whatwaspicked=0
EndIf



mintybreath(Posted 2007) [#3]
That worked great, thanks for your help Yahfree!