只要編輯出粒子效果,那在cocos2d-x引擎中加載plist文件就很是簡單了。使用如下代碼來讀取粒子效果:函數
//貼背景圖片 Sprite* pSprite = Sprite::create("IMG1.jpg"); pSprite->setPosition(Point(-20 , 0)); pSprite->setAnchorPoint(Point(0, 0)); this->addChild(pSprite, 0); //讀取粒子效果 ParticleSystem* m_emitter1 = ParticleSystemQuad::create("snow.plist"); m_emitter1->retain(); ParticleBatchNode *batch = ParticleBatchNode::createWithTexture(m_emitter1->getTexture()); batch->addChild(m_emitter1); addChild(batch, 10); m_emitter1->release(); //或讀取粒子效果 //ParticleSystem* m_emitter1 = ParticleSystemQuad::create("snow.plist"); //addChild(m_emitter1);
這裏ParticleBatchNode能夠引用且只能夠引用1個texture(一個圖片文件,一個texture圖集),增長到SpriteBatchNode中的ParticleSystem都是在OpenGL ES調用繪圖函數時繪製的。this
若是ParticleSystem沒有增長到ParticleBatchNode中,OpenGL ES會調用每一個粒子系統的繪圖函數,這樣作效率會比較低。code