Reputation: 3012
I'm making a game with Swift
and Sprite Kit
.
I would like to add background music and sound effects.
The "classic" way is to use AVFoundation
, but this does not seem to have new Swift APIs, only Objective C
ones.
Is there a new modern swift sound API I can use with Sprite Kit easily?
Upvotes: 0
Views: 2118
Reputation: 126167
No frameworks have new Swift APIs in iOS 8 or OS X Yosemite. All Objective-C frameworks are automatically bridged to Swift, and those include both SpriteKit and AVFoundation.
If you're looking for a quick high-level alternative to the more detailed AVFoundation APIs for adding sounds and music to your game, look no further than SpriteKit itself. (Regardless of whether you use Swift or Objective-C.)
SKAction
provides a playSoundFileNamed:waitForCompletion:
action. Pass false
for the second parameter to play sound effects, or pass true
and make a repeating action to loop music.
Upvotes: 2