How to stop a audio SKAction?

前端 未结 2 1365
有刺的猬
有刺的猬 2020-12-07 00:48

Goal: I want to present a new scene:

[self.scene.view presentScene:level2 transition:reveal];

and end the current background music in orde

2条回答
  •  隐瞒了意图╮
    2020-12-07 01:28

    Now you can stop playing sound action by assigning key string for it then using removeActionForKey later

    Sorry, this is Swift. But it can be ported to Obj-C.

    let action: SKAction = SKAction.playSoundFileNamed("sounds/boom.wav", waitForCompletion: true)
    self.runAction(action, withKey:"die-sound")
    // later you do:
    self.removeActionForKey("die-sound")
    

    I have tested successful

提交回复
热议问题