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的更多相关文章
随机推荐
- SharePoint的实体生成
生成Linq实体 使用SPMetal工具生成Linq to SharePoint实体 工具安装目录: C:\Program Files\Common Files\Microsoft Shared\We ...
- openerp学习笔记 context 的应用
1.在Action中定义,context用于传递搜索条件和分组条件,在搜索视图中默认显示: 示例代码: <record model="ir.actions.act_window&quo ...
- [Swift系列]002-基础语法
基础语法就那老几样,很快可以说完 [常量.变量] 1.变量用 var,系统自动去判断类型,但变量再次赋值需保持数据类型一致 var a=50 相信用过js/java/C#的,对这个var都不陌生 使 ...
- ISO中AFN的使用步骤
1.依赖的框架 * MobileCoreServices.framework * SystemConfiguration.framework * Security.framework 2.主头文件:A ...
- hibernate封装查询,筛选条件然后查询
// 封装查询条件 @Test public void transmitParameter() { Map map = new HashMap<String, String>(); // ...
- 戴维·卡梅伦(David William Donald Cameron)经典语录
戴维·威廉·唐纳德·卡梅伦(英语:David William Donald Cameron,1966年10月9日-),汉化译名为甘民乐.现任英国首相.第一财政大臣.公务员事务部部长和保守党党魁,也是英 ...
- Android Studio你不知道的调试技巧
写代码不可避免有Bug,通常情况下除了日志最直接的调试手段就是debug:那么你的调试技术停留在哪一阶段呢?仅仅是下个断点单步执行吗?或者你知道 Evaluate Expression, 知道条件断点 ...
- rsync同步时报“auth failed on module”错误的可能原因
关于这个auth失败的问题,有以下可能的情况: 1.密码输入错误: 请再次确认你登录用户的密码无误 2.secrets file格式错误: secrets file的文件格式是 upload ...
- library cache lock和cursor: pin S wait on X等待
1.现象: 客户10.2.0.4 RAC环境,出现大量的library cache lock和cursor: pin S wait on X等待,经分析是由于统计信息收集僵死导致的.数据库在8点到9点 ...
- centos 安装mysql 登录进提示 Access denied for user 'root'@'localhost' (using password: NO)
# service mysqld stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql ...