我根据 spark 模板创建了一个 .sks 粒子发射器。 我的应用程序是一个普通的应用程序(不是游戏)。当用户点击一个按钮时,我有一个新的View控制器,它在全屏上显示模态,这样我就可以模糊背景。
I created an .sks particle emitter based on the spark template. My app is a normal app (not a game). When a user clicks a button, I have a new View controller that shows modally over fullscreen so that I can blur the background.
在这个模态中,我创建了一个视图并给它一个 SCNView 见下图:
In this modal, I created a view and gave it a class of SCNView see image below:
如何在粒子视图中加载粒子 .sks 文件以在该viewController上执行动画?
How can I load the particle .sks file to do the animation on that viewController on the Particles view?
更新 如何在视图控制器中加载SceneKit粒子系统?
Update How to load a SceneKit particle systems in view controller?
推荐答案如@mnuages所述,您可以使用 .scnp 文件而不是 .sks ,这是一个SceneKit粒子系统。
As mentioned by @mnuages, you can use .scnp file instead of .sks, which is a SceneKit Particle System.
所以步骤是:
在你的 UIViewController 中:
In your UIViewController:
class SomeVC:UIViewController {
@IBOutlet weak var particles: SCNView! override func viewDidLoad() { super.viewDidLoad() let scene = SCNScene() let particlesNode = SCNNode() let particleSystem = SCNParticleSystem(named: "ConfettiSceneKitParticleSystem", inDirectory: "") particlesNode.addParticleSystem(particleSystem!) scene.rootNode.addChildNode(particlesNode) particles.scene = scene }}
Et Voila ......你有动画:)
Et Voila...you have you animation :)
更多推荐
在视图控制器中添加火花粒子精灵
发布评论