Hey, when i try to run sound action with sprite kit it crashes even at sprite kit's default template as you see below. I tried directly adding self.runAction(SKAction.playSoundFileNamed("bounce.mp3", waitForCompletion: false) to touchesbegan too but it crashes when i click this time.
I think it crashes when its trying to declare play sound action to memory. Its like it cant get my audio file. It says libc++abi.dylib: terminating with uncaught exception of type NSException. Im a C++ programmer and this is my first app with swift and sprite kit. Any help will be very very appreciated.
import SpriteKit
class GameScene: SKScene {
var bouncesound = SKAction()
override func didMoveToView(view: SKView) {
bouncesound = SKAction.playSoundFileNamed("bounce.mp3", waitForCompletion: false)
/ Setup your scene here */
let myLabel = SKLabelNode(fontNamed:"Chalkduster")
myLabel.text = "Hello, World!";
myLabel.fontSize = 65;
myLabel.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame));
self.addChild(myLabel)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/ Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"Spaceship")
sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
self.runAction(bouncesound)
}
}
override func update(currentTime: CFTimeInterval) {
/ Called before each frame is rendered */
}
}