I'm interested in how I can manage background music in my Sprite Kit game to achieve fade in/out.
I noticed that Sprite Kit has a built-in sound player, but it seems to be more useful for very short effects, like "on hit" sounds:
[self runAction:[SKAction playSoundFileNamed:@"music.mp3" waitForCompletion:NO]];
It does not seem like there's a way to stop this sound.
I'm using Kobold Kit, and it comes with OALSimpleAudio library that can play sounds:
[[OALSimpleAudio sharedInstance] preloadEffect:@"die.wav"];
[[OALSimpleAudio sharedInstance] playEffect:@"die.wav"];
[[OALSimpleAudio sharedInstance]preloadBg:@"battle.mp3"];
[[OALSimpleAudio sharedInstance] playBg:@"battle.mp3" loop:YES];
There's a bgVolume
property in OALSimpleAudio
, but no real fade.
Should try to write my own fade in/out code of if there's something out there I can use to control volume over time of a generic music player, like OALSimpleAudio.