OperateParticleWithCodes
【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的更多相关文章
随机推荐
- 【笨嘴拙舌WINDOWS】Dj,oh!nonono,It is about DC
“DC: Device content 设备描述表.通常指显示器,或者打印机设备的描述” 如果你不是从事打印机方面的编程,那么就可以将DC简单的理解为显示器的属性表.WINDOWS将内存里面的东西通过 ...
- HDU 2144 (最长连续公共子列 + 并查集) Evolution
我发现我一直理解错题意了,这里的子序列指的是连续子序列,怪不得我写的LCS一直WA 顺便复习一下并查集 //#define LOCAL #include <iostream> #inclu ...
- 51nod1239 欧拉函数之和
跟1244差不多. //由于(x+1)没有先mod一下一直WA三个点我... //由于(x+1)没有先mod一下一直WA三个点我... #include<cstdio> #include& ...
- adapter适配器模式
适配器设计模式概述 将一个类的接口转换成另外一个客户希望的接口.从而使原来不能直接调用的接口变得可以调用 优点: 让本来不适合使用的接口变得适合使用 缺点: 一次只能适配一个类,具有 ...
- POJ 2125 Destroying The Graph (二分图最小点权覆盖集+输出最小割方案)
题意 有一个图, 两种操作,一种是删除某点的所有出边,一种是删除某点的所有入边,各个点的不同操作分别有一个花费,现在我们想把这个图的边都删除掉,需要的最小花费是多少. 思路 很明显的二分图最小点权覆盖 ...
- OK335xS ethtool 移植
/******************************************************************* * OK335xS ethtool 移植 * 声明: * 由于 ...
- linux vim 配置文件(高亮+自动缩进+行号+折叠+优化)
点评:将一下代码copy到 用户目录下 新建文件为 .vimrc保存即可生效 如果想所有用户生效 请修改 /etc/vimrc (建议先cp一份)"===================== ...
- Azure PowerShell 1.0.0以上版本在中国Azure使用的注意事项
随着Azure PowerShell 1.0.0+的推出,越来越多的客户开始使用新的版本的Azure PowerShell.此版本的PowerShell最大的改变在于将原先的Switch-AzureM ...
- linux 命令行字符终端terminal下强制清空回收站
回收站其实就是一个文件夹,存放被删掉的文件. ubuntu 回收站的路径: $HOME/.local/share/Trash/ 强制清空回收站: rm -fr $HOME/.local/share/T ...
- swun 1388 你的背包
解题思路:这题给人的第一反应是背包,第二反应是贪心,我用的是搜索,枚举就可以,要有这种意识, 题目数据只有8个,暴力是可以解决的. #include<cstdio> #include< ...