I'm assuming that XACT Cues are the equivalent of SoundInstances. I can play a cue:
laserCues[0].Play();
And stop a cue:
laserCues[0].Stop(AudioStopOptions.Immediate);
But how do I play that Cue again? The following gives an error - "The method or function that was called cannot be used in the manner requested":
laserCues[0].Play();
VulpesPosted Aug 14, 2011, 10:04 AM
VulpesPosted Aug 14, 2011, 1:24 PM
time and spacePosted Aug 14, 2011, 12:06 PM
I'm currently managing cue instances using an array of Cues. This allows me to stop a sound which is linked to an event/object, eg - if an enemy is firing a continuous laser (looped cue), and that enemy is destroyed, the laser cue is also stopped. The cue index is stored in a field in the enemy class (short linkIndex). Eg:
//Enemy spawn
laserCues[enemy.linkIndex] = soundBank.GetCue("Laser3");
laserCues[enemy.linkIndex].Play();
//Enemy destroyed
laserCues[enemy.linkIndex].Stop(AudioStopOptions.Immediate);
Is there a more elegant way of doing this? You can set the number of instances of a cue in the XACT tool. Is there a unqiue identifier for each cue instance so I could use that in my code rather than having to create an array of cues?