Loop sound while keydown
BlitzMax Forums/BlitzMax Beginners Area/Loop sound while keydown
| ||
I'm trying to play a burning sound while holding the acceleration key button... I'v tried loading a sound into loop mode, then trying to play the sound while the key is pressed, then not when its not held down.. but failed so far.. Any ideas? |
| ||
if keydown(?) if not channelplaying(?) then playsound(?,?) else if channelPlaying(?)then stopchannel(?) endif |
| ||
woops, no wonder i'm not getting a responce.... thought i already replyed I tried this before, and it didnt work, i get the error: Unable to convert something.audio.TSound to TChannel heres my code at the moment: If KeyDown(KEY_UP) 'Afterburner effect Local par1:TPartical = New TPartical par1.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par2:TPartical = New TPartical par2.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par3:TPartical = New TPartical par3.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par4:TPartical = New TPartical par4.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par5:TPartical = New TPartical par5.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) vx:+Cos(angle)*accel vy:+Sin(angle)*accel If Not ChannelPlaying(afterburn) PlaySound(afterburn) Else If ChannelPlaying(afterburn) StopChannel(afterburn) EndIf and i'm loading it like this: Global afterburn:TSound = LoadSound("Media\afterburn.wav",SOUND_LOOP) thanks for the help :) |
| ||
You seem to be checking whether a channel is playing but using a TSound to check it. e.g. afterburn is a TSound and not a TChannel. |
| ||
how do i make it a channel? i tried changing: Global afterburn:TSound = LoadSound("Media\afterburn.wav",SOUND_LOOP) to Global afterburn:TChannel = LoadSound("Media\afterburn.wav",SOUND_LOOP) still, an error.. I'm stumped.. |
| ||
Slightly edited from the doc...' channelplaying.bmx sound:tsound = LoadSound ("shoot.wav") Input "Hit return to begin channelplaying test, use ctrl-C to exit" channel:tchannel=playsound (sound) while true print "ChannelPlaying(channel)="+ChannelPlaying(channel) wend you can also use the allocchannel cmd |
| ||
it should be something like this:Global aftchannel:TChannel = AllocChannel() and this: . . . . If KeyDown(KEY_UP) 'Afterburner effect Local par1:TPartical = New TPartical par1.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par2:TPartical = New TPartical par2.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par3:TPartical = New TPartical par3.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par4:TPartical = New TPartical par4.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) Local par5:TPartical = New TPartical par5.Create(x-(Cos(angle))*10,y-Rand(-2,8)-(Sin(angle))*10,20) vx:+Cos(angle)*accel vy:+Sin(angle)*accel If Not ChannelPlaying(aftchannel) PlaySound(afterburn,aftchannel) Else If ChannelPlaying(aftchannel) StopChannel(aftchannel) EndIf |
| ||
seems to work, thanks |