2

I think I've got my game working almost the same as it was before iOS 9 came along...

I have included the entire function, but the only thing I am having a problem with is the sound effect at the beginning of the function:

func collisionHappened() {
       let bangSoundEffect = SKAction.playSoundFileNamed("Bang.mp3", waitForCompletion: false)
        runAction(bangSoundEffect) //nothing happens here

    let defaults = NSUserDefaults()
    let highscore = defaults.integerForKey("highscore")
    if (score > highscore){
        defaults.setInteger(score, forKey: "highscore") }
    var showHighScore = defaults.integerForKey("highscore")
    let userDefaults = NSUserDefaults.standardUserDefaults()
    var totalScore = userDefaults.integerForKey("totalScoreKey")
    totalScore += self.score
    userDefaults.setInteger(totalScore, forKey: "totalScoreKey")
    var current = defaults.integerForKey("currentscore")
    defaults.setInteger(score, forKey: "currentscore")
    var showcurrentscore = defaults.integerForKey("currentscore")
     backgroundMusicPlayer.stop()
 let explosion = SKEmitterNode(fileNamed: "rocketExplosion") { 
    explosion.position = rocket.position
    explosion.zPosition = 100
    addChild(explosion) }

    rocket.removeFromParent() 
    let sceneChange = gameOverScene(size: self.size) //change scene
    sceneChange.scaleMode = scaleMode
    let reveal = SKTransition.crossFadeWithDuration(1.5)
    self.view?.presentScene(sceneChange, transition: reveal)
    reveal.pausesOutgoingScene = false }

Working fine for iOS 8, but nothing happens in iOS 9. What's changed?? There is no error, its just that nothing happens anymore. If it makes a difference, the sound effect is about half a second long.

UPDATE: I tried adding a println() (which is now print lol) to this function to make sure it's there's no problems with my collisions and its being called. It is, and the rest of the function work fine so the problem only lies with the SKAction :(

JGrn84
  • 750
  • 1
  • 9
  • 26
  • 1
    can you be more specific ? Is there any error ? Or just there is no sound ? – Whirlwind Sep 22 '15 at 20:50
  • There's no error, but just no sound. I'll edit my question to include the whole function. – JGrn84 Sep 23 '15 at 13:31
  • @kellcix If there are no errors, first make sure if that code is actually executed. Put some println() right before that action. It could be that collision is not detected properly or something similar. Otherwise, it could be that is iOS9 related issue ... A lot of people complaining that something which worked in iOS8 perfectly,on iOS9 doesn't work anymore :( – Whirlwind Sep 23 '15 at 13:37
  • Thank you :) I'll try the println(). Hopefully if it is an iOS9 thing they'll sort it out soon! – JGrn84 Sep 23 '15 at 13:40
  • Same issue, work on iOs10 but not in iOs9 any solution? – Maetschl Oct 21 '16 at 17:52

1 Answers1

0

I find the answer...maybe help you

self.runAction(SKAction.playSoundFileNamed(“Achievement.caf”, waitForCompletion: false))
Mark Zhang
  • 31
  • 2