I upgraded my Sprite Kit game to X-Code 8.0 and Swift 3 yesterday. Deployment target is currently set to iOS 9.3.
I play sound effects the following way:
self.run(SKAction.playSoundFileNamed("click.caf", waitForCompletion: false))
The sound effect is not played correctly (only about the half of the samples) and I get the following error (since upgrade to X-Code 8.0 and Swift 3):
SKAction: Error playing sound resource
Any ideas ?
The problem disappeared when I removed this preload code. Do you have something similar? But now I get a short delay the first time a sound is played. Don't know how I shall handle that.
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Preload sounds
[SKAction playSoundFileNamed:@"coinBlip.wav" waitForCompletion:NO];
[SKAction playSoundFileNamed:@"bonus.wav" waitForCompletion:NO];
:
My bug report (28350796) has been fixed now, and I've verified it on iOS 10.2 in beta simulator. So add a new bug report if your problems still exist on iOS 10.2!
I found a solution that works with me. I use a computed SKAction sound property instead of preloaded sounds:
var enemyCollisionSound: SKAction { return SKAction.playSoundFileNamed("hitCatLady.wav", waitForCompletion: false) }
I'm also having this issue and I've tracked it down to if a node is trying to play a sound and it has created an instance of another object within its code and that object has preloaded audio code, the node that created the other will not play its sounds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With