channelplaying help
BlitzMax Forums/BlitzMax Beginners Area/channelplaying help| 
 | ||
| hey guys I am trying to play a laser sound when you press the spacebar however to not have the sound play a million times as im using the keydown(key_space) command. I am trying to use this code but it says attempt to access null field. btw i am using superstrict here is my the sound part of my code: 
Global channel:TChannel
Global laser:TSound = LoadSound("L1.wav")
If KeyDown(key_space)
	If ChannelPlaying(channel) = 0
		channel = PlaySound (laser)
	EndIf
endif
i am not sure if i am using it right or not. any help would be greatly appreciated. Thanks again! B | 
| 
 | ||
| This code should work. Add a test if the soundfile is loaded: 
Global laser:TSound = LoadSound("L1.wav")
if laser=NULL then throw("Can't load sound")
 | 
| 
 | ||
| You need to create the TChannel.  You have declared it, but you have not actually created it yet. | 
| 
 | ||
| @TaskMaster using the cue:tchannel command? EDIT: ok I got it working by using: channel = AllocChannel() ps - you can download my space game which i am working on right now using the link in my sig however it is only for mac now. | 
| 
 | ||
| DELETED POST |