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的更多相关文章
随机推荐
- 二维线性表 list实现
class Coordinate{ private int x; private int y; } List<Coordinate> list=new ArrayList<Coord ...
- Codeforces 377 A Maze【DFS】
题意:给出n*m的矩阵,矩阵由'.'和'#'组成,再给出k,表示需要在'.'处加k堵墙,使得剩下的'.'仍然是连通的 先统计出这个矩阵里面总的点数'.'为sum 因为题目说了一定会有一个解,所以找到一 ...
- memcached内存管理及key value长度限制
1)什么是内存碎片?内存是大小有限的资源.例如把内存比作一张小床,来了一个小伙伴,可以睡下,再来一个小伙伴也能睡下.现在两个人了,他们点了差不多的大小的位置(资源),位置还有剩下.然后再来一个小胖子, ...
- BZOJ 1617 渡河问题
普及组dp. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...
- The Guide To Understanding mysqlreport
The Guide To Understanding mysqlreport This guide to understanding mysqlreport explains everything t ...
- struts2拦截器配置;拦截器栈;配置默认拦截器;拦截方法的拦截器MethodFilterInterceptor;完成登录验证
struts2.xml 内容 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts ...
- 聊聊Dataguard的三种保护模式实验(上)
Data Guard是Oracle高可用性HA的重要解决方案.针对不同的系统保护需求,DG提供了三种不同类型的保护模式(Protection Mode),分别为:最大保护(Maximum Protec ...
- 正确理解 AsyncTask,Looper,Handler三者之间的关系(基于android 4.0)
Looper 和Handler 是理解好AsyncTask的一个基础,我们可以先从这里开始,先给出一个主线程和子线程互相通信的例子. package com.example.loopertest; i ...
- NoSQL架构实践(一)——以NoSQL为辅
前面<为什么要使用NoSQL>和<关系数据库还是NoSQL数据库>两篇从大体上介绍了为什么要用NoSQL,何时该用NoSQL.经常有朋友遇到困惑,看到NoSQL的介绍,觉得很好 ...
- 3500常用汉字与标点符号(已排除不支持GB2312的)
.?!,.::“”‘’…()<>〈〉[].,:;!?-'_"'()[]<>|&~;+-*/=<>0123456789ABCEFGHIJKLMNOP ...