OperateParticleWithCodes

  Listing 6-6 shows how you might configure an emitter’s scale property. This is a simplified version of a node’s xScale and yScale properties, and determines how large the particle is.

  

Using Keyframe Sequences to Configure Custom Ramps for a Particle Property

  

Adding Actions to Particles

  Although you do not have direct access to the particles created by Sprite Kit, you can specify an action that all particles execute. Whenever a new particle is created, the emitter tells the particle to run that action. You can use actions to create very sophisticated behaviors.

  For the purpose of using actions on particles, you can treat the particle as if it were a sprite. This means you can perform other interesting tricks, such as animating the particle’s textures.

Using Target Nodes to Change the Destination of Particles

  When an emitter has a target node, it calculates the position, velocity, and orientation of the particle, exactly as if it were a child of the sprite node. This means that if the ship sprite is rotated, the exhaust orientation is automatically rotated also. However, at the moment a new particle’s starting values are calculated, the values are transformed into the target node’s coordinate system. Thereafter, they would only be affected by changes to the target node.

Particle Emitter Tips

  Particle emitters in Sprite Kit are one of the most powerful tools for building visual effects. However, used incorrectly, particle emitters can be a bottleneck in the design and implementation of your app. Consider the following tips:

  • Use Xcode to create and test your particle effects, then load the archives in your game.
  • Adjust emitter properties sparingly inside your game code. Typically, you do this to specify properties that cannot be specified in the Xcode inspector or to control properties inside your game logic.
  • Particles are cheaper than a sprite node, but they still have overhead! Try to keep the number of particles onscreen to a minimum by creating particle emitters with a low birth rate, and specifying a short lifetime for particles. For example, instead of creating hundreds or thousands of particles per second, reduce the birth rate and increase the size of the particles slightly. Often, you can create effects with fewer particles but the same net visual appearance.
  • Use actions on particles only when there isn’t another solution. Executing actions on individual particles is potentially very expensive, especially if the particle emitter also has a high birth rate.
  • Assign a target node whenever the particles should be independent of the emitter node after they are spawned. For examples, particles should be independent if the emitter node moves or rotates in the scene.
  • Consider removing a particle emitter from the scene when it is not visible onscreen. Add it just before it becomes visible.

OperateParticleWithCodes的更多相关文章

随机推荐

  1. 如何直接在github网站上更新你fork的repo?

    玩过github的人一定会在你自己的账号上fork了一些github开源项目.这些开源项目往往更新比较活跃,你今天fork用到你自己的项目中去了,过几个星期这个fork的origin可能有一些bugf ...

  2. Kafka的Producer和Consumer源码学习

    先解释下两个概念: high watermark (HW) 它表示已经被commited的最后一个message offset(所谓commited, 应该是ISR中所有replica都已写入),HW ...

  3. Linux mv 命令的10个实用例子

    当你想要将文件从一个位置移动到另一个地方并且不想复制它,那么mv 命令是完成这个任务的首选.本文中总结了十个Linux mv 命令的实例,希望能给大家带来一些帮助. 初识 mv 命令 mv 命令是一个 ...

  4. PHP无法加载MySQL模块

                在 将PHP根目录下libmysql.dll复制到c:\Windows\system32中 在Apache目录中的conf\httpd.conf 中加载libmysql.dll ...

  5. jupyterhub

    pkill jupyterhub #激活python环境 pyenv activate jupyterhub #启动jupyterhub /fly/start_jupyterhub.sh cd ~/r ...

  6. 学习java之利用泛型访问自己定义的类

    如果有多个类,而且他们其中有一些方法是相同的,我是选择在每个类中都把这些方法实现一遍呢,还是选择泛型.我今天自己花了一点时间看了看泛型,实践了一下. Holder.java package regex ...

  7. 文件IO

    在unix世界中视一切为文件,无论最基本的文本文件还是网络设备或是u盘,在内核看来它们的本质都是一样的.大多数文件IO操作只需要用到5个函数:open . read . write . lseek 以 ...

  8. SkinPP for VC

    1.下载文件:SkinPPWTL.h,SkinPPWTL.dll,SkinPPWTL.lib以及Skin++皮肤库: 2.新建一个工程,如:基于多文档的工程,名为:MySkin: 3.将下载的Skin ...

  9. acess() 判断目录是否存在

    acess()功能描述: 检查调用进程是否可以对指定的文件执行某种操作. <pre lang="c" escaped="true">#include ...

  10. 搭建 MPICH3 并行计算环境

    先记录在单机MacBook上的搭建,实验室集群的搭建流程是一样的,不过每台机器都需要做一次. MacBook: 1.安装mpich3: $ ./configure --prefix=/Users/xi ...