在视图控制器中添加火花粒子精灵

编程入门 行业动态 更新时间:2024-10-04 09:28:52
本文介绍了在视图控制器中添加火花粒子精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我根据 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 :)

  • 更多推荐

    在视图控制器中添加火花粒子精灵

    本文发布于:2023-11-29 15:24:20,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1646790.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:粒子   视图   火花   器中   精灵

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!