本文来自http://blog.youkuaiyun.com/runaying ,引用必须注明出处!
cocos2d-x节点(CCParticleSystemQuad.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
ParticleSystemQuad 是 ParticleSystem的子类,它包含 ParticleSystem的所有功能, 增加了,缩放、旋转、批处理
///cocos2d-x-3.0alpha0/cocos2dx/particle_nodes
//ParticleSystemQuad 是 ParticleSystem 的子类,它包含 ParticleSystem 的所有功能, 增加了,缩放、旋转、批处理
#ifndef __CC_PARTICLE_SYSTEM_QUAD_H__
#define __CC_PARTICLE_SYSTEM_QUAD_H__
#include "CCParticleSystem.h"
NS_CC_BEGIN
class SpriteFrame;
/**
* @addtogroup particle_nodes
* @{
*/
/** @brief ParticleSystemQuad 是 ParticleSystem 的子类
它包含 ParticleSystem 的所有功能.
特殊功能和限制:
- Particle size can be any float number. //粒子尺寸可以是任意 float 数字.
- The system can be scaled //该系统可缩放
- The particles can be rotated //这些粒子可以是旋转
- It supports subrects //它支持主题
- It supports batched rendering since 1.1 //从 1.1 开始,它支持批处理渲染
@since v0.8
*/
class CC_DLL ParticleSystemQuad : public ParticleSystem
{
public:
/** 创建一个粒子发射器 */
static ParticleSystemQuad * create();
/**使用 粒子数 创建一个粒子发射器 */
static ParticleSystemQuad * createWithTotalParticles(unsigned int numberOfParticles);
/** 从一个plist文件初始化一个 ParticleSystemQuad,这个plist文件可以手动创建或者使用 Particle Designer 创建
*/
static ParticleSystemQuad * create(const char *plistFile);
/**
* @js ctor
*/
ParticleSystemQuad();
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSystemQuad();
/** 初始化顶点的 indices(指数) */
void initIndices();
/** 使用 矩形测量点 初始化一个 texture */
void initTexCoordsWithRect(const Rect& rect);
/** 把一个新的 SpriteFrame 设置为 particle.
WARNING: 这个方法正在实验. 请使用 setTextureWithRect 替代.
@since v0.99.4
*/
void setDisplayFrame(SpriteFrame *spriteFrame);
/** 使用 rect 设置一个新的 texture.这个 rect 是 Points 组成的.
@since v0.99.4
* @js NA
* @lua NA
*/
void setTextureWithRect(Texture2D *texture, const Rect& rect);
/** 监听 android的 “coming to foreground”事件
* @js NA
* @lua NA
*/
void listenBackToForeground(Object *obj);
// Overrides
/**
* @js NA
* @lua NA
*/
virtual bool initWithTotalParticles(unsigned int numberOfParticles) override;
/**
* @js NA
* @lua NA
*/
virtual void setTexture(Texture2D* texture) override;
/**
* @js NA
* @lua NA
*/
virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition) override;
/**
* @js NA
* @lua NA
*/
virtual void postStep() override;
/**
* @js NA
* @lua NA
*/
virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void setBatchNode(ParticleBatchNode* batchNode) override;
/**
* @js NA
* @lua NA
*/
virtual void setTotalParticles(int tp) override;
private:
#if CC_TEXTURE_ATLAS_USE_VAO
void setupVBOandVAO();
#else
void setupVBO();
#endif
bool allocMemory();
protected:
V3F_C4B_T2F_Quad *_quads; // quads to be rendered //要呈现的四边形
GLushort *_indices; // indices //指数
#if CC_TEXTURE_ATLAS_USE_VAO
GLuint _VAOname;
#endif
GLuint _buffersVBO[2]; //0: vertex 1: indices //顶点 指数
};
// end of particle_nodes group
/// @}
NS_CC_END
#endif //__CC_PARTICLE_SYSTEM_QUAD_H__