audio - Stoping a sound as an action on a node with a key in SceneKit -
i've written function in scenekit plays background music action on node key stop music playing using key
i have global variable can call stop action anywhere in class, (by way scenekit not spritekit, still using swift language though)
var musicplayingaction = scnaction()
however nothing stops it, either forkey or removeallactions in...
this nothing
scnscene.rootnode.removeactionforkey("bgmusickey")
so try higher level , drill down, killing actions either on scene, view or node (depending on attach sound action).
self.scnview.scene!.rootnode.removeallactions()
still nothing...
even if run sound action on specific node , try kill that.. guessed nothing or should music still playing.
this function
func playmusic() { if game.state == .playing { let music = scnaudiosource(filenamed: "art.scnassets/sounds/bgmusic.mp3")! music.volume = 0.3; music.loops = true music.shouldstream = true music.positional = false musicplayingaction = scnaction.playaudiosource(music, waitforcompletion: false) scnscene.rootnode.runaction(musicplayingaction, forkey: "bgmusickey") } }
the action works in music plays not stop.
is possible stop audiosource action, know can stop actions key, although first time have tried stop audio scnaction (note not skaction) key???
any ideas appreciated, thanks.
solved!
removed action forkey...
split game scenes, added game state each scene, loaded background music dependant on state & scene.
thanks help, appreciated =)
Comments
Post a Comment