重复时,Skaction.playsoundfilenamed崩溃 - 精灵工具包 [英] Skaction.playsoundfilenamed crashes when repeat - sprite kit

查看:217
本文介绍了重复时,Skaction.playsoundfilenamed崩溃 - 精灵工具包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的精灵工具包SKAction.playSoundFileNamed有问题。
在实践中,经过一段时间它正确播放,应用程序崩溃说它不会加载。
文件包含在捆绑导入中,项目文件存在且一切都设置正确。



唯一的问题,经过一段时间我玩,我会崩溃说它无法找到文件,或者至少无法加载。



我的问题是,每次声音SKAction.playSoundFileNamed有没有办法充电? / p>

编辑 - 已解决

  // init 
var sound = SKAction.playSoundFileNamed(sound.mp3,waitForCompletion:false)
var sound2 = SKAction.playSoundFileNamed(sound2.mp3,waitForCompletion:false)

//在代码调用函数中播放声音时:
playSound(声音)

...

func playSound(soundVariable:SKAction)
{
runAction(soundVariable)
}

实例化的预加载声音不再生成崩溃

解决方案

prelound声音变量

  // init 
var sound = SKAction.playSoundFileNamed(sound.mp3,waitForCompletion:false)
var sound2 = SKAction.playSoundFileNamed(sound2.mp3,waitForCompletion:false)
播放声音时代码调用函数
//:
playSound(声音)

...

func playSound(soundVariable:SKAction)
{
runAction(soundVariable)
}


I have a problem with sprite kit SKAction.playSoundFileNamed. In practice, after some time it is played correctly , the app crashes saying it will not load . The file is included in the bundle import the project file exists and everything is properly set.

The only problem , after some time I play, I will crash saying it can not find the file , or at least can not be loaded .

My question is , is there a way to recharge every time the sound SKAction.playSoundFileNamed ?

EDIT - SOLVED

//init
var sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false)
var sound2 = SKAction.playSoundFileNamed("sound2.mp3", waitForCompletion: false) 

//in the code call function when play sound:
playSound(sound)

...

func playSound(soundVariable : SKAction)
{
    runAction(soundVariable)   
}

The preload sounds instantiated no longer generates crash

解决方案

prelound sound variable

//init
var sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false)
var sound2 = SKAction.playSoundFileNamed("sound2.mp3", waitForCompletion: false) 

//in the code call function when play sound:
playSound(sound)

...

func playSound(soundVariable : SKAction)
{
    runAction(soundVariable)   
}

这篇关于重复时,Skaction.playsoundfilenamed崩溃 - 精灵工具包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆