SKEmitterNode iOS 9 GM问题 [英] SKEmitterNode iOS 9 GM problems

查看:57
本文介绍了SKEmitterNode iOS 9 GM问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在iOS 8中用来显示粒子的代码:

This is the code I used in iOS 8 to get the particle to appear:

func onCollision() {    
let explosion = SKEmitterNode(fileNamed: "rocketExplosion") 
        explosion.position = rocket.position
        explosion.zPosition = 100
        addChild(explosion) 
}

在iOS 8上运行良好,但在iOS 9上运行不正常.我已经了解到Beta版中的粒子发射器存在问题,它们在GM版本中是否仍然相同?另外,我在"Swift 2"教程之后尝试了此方法,但是没有运气:

Worked fine for iOS 8 but not for iOS 9. I've read that there were problems with the particle emitters in the beta, are they still the same in GM version? Also, I tried this after a "Swift 2" tutorial but no luck:

 if let explosion = SKEmitterNode(fileNamed: "rocketExplosion") {
        explosion.position = rocket.position
        explosion.zPosition = 100
        addChild(explosion) }

推荐答案

希望这对您有所帮助

let explosionFile: String = NSBundle.mainBundle().pathForResource("rocketExplosion", ofType: "sks")!
let explosion = NSKeyedUnarchiver.unarchiveObjectWithFile(explosionFile) as! SKEmitterNode
explosion.position = rocket.position
explosion.zPosition = 100
self.addChild(explosion)

这篇关于SKEmitterNode iOS 9 GM问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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