What Sphere v2 gives you the option is to do most of those steps in advance. It's up to you to decide when it's appropriate to do so, just don't make the mistake of thinking calling a bunch of blit() calls every frame is going to be magically faster than creating all those textured quads manually on the fly. It won't be--because that's exactly what the engine is going to do on your behalf.
I guess I'd think that having those low level steps done in the compiled engine rather than with extra calls from a script may be slightly faster?
if(is_making_sound(mixers[mixers.length-1])){ mixers.push(newMixer(blah,bla));}sound.play(mixers[mixers.length-1]);
sound.clone().play()
function SoundEffect(filename){ this.queue = [LoadSound(filename)]; this.name = filename;}SoundEffect.prototype.play = function(){ if(this.queue[this.queue.length-1].isPlaying()==false) { this.queue.unshift(this.queue.pop()); // this.queue[0].stop(); } else { this.queue.unshift(LoadSound(this.name)); } this.queue[0].play();}
Sound#play([mixer]); Begins or resumes sound playback. When called with no `mixer` argument, Sound#play() will resume playback for a paused sound. Otherwise, the sound is started from the beginning on the specified mixer.
var sound = new Sound('sounds/test.wav');sound.play(Mixer.Default);
Hmm - using Mixer.default works, but when I tried creating a Mixer it didn't work it just gave no output.
Any thoughts on the other point about v1 (requiring the .stop() command)
Also is there a way to have the same sound playing multiple times with v2 without something like the sound queue I showed above?
// 44.1kHz, 16-bit, stereo, i.e. CD qualityMixer.Default = new Mixer(44100, 16, 2);
One other query at the same time:Sphere v1 var sound = LoadSound("blah.ogg");Sphere v2 var sound = new Sound("sounds/blah.ogg")Why does v2 not default to the sounds folder?
would like to be able to have an in game volume control menu with sound effects and music separate - which I assume this will enable.
let sample = new Sample('sounds/munch.wav');while (Sphere.run()) { key = Keyboard.Default.getKey(); if (key == Key.Space) sample.play(Mixer.Default);}