在视图控制器中添加火花粒子精灵 [英] Adding a spark particle sprite inside a view controller
问题描述
我根据 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.
所以步骤是:
- 创建一个SceneKit粒子系统,我打电话它
ConfettiSceneKitParticleSystem.scnp
- 然后在你的画板中,选择视图并选择类
SCNView
就像在问题的版画屏幕中一样 -
在你的
UIViewController
中:
- Create a SceneKit Particle System, I called it
ConfettiSceneKitParticleSystem.scnp
- Then in your art-board, select the view and select the class
SCNView
for it like in the printscreen of the question 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 :)
这篇关于在视图控制器中添加火花粒子精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!