Merge pull request #4834 from minggo/bug-fix

Put "initxx" functions into protected.
This commit is contained in:
minggo 2014-01-03 03:27:55 -08:00
commit 5ad3414921
4 changed files with 22 additions and 27 deletions

View File

@ -73,22 +73,13 @@ public:
/** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */
static ParticleBatchNode* create(const std::string& fileImage, int capacity = kParticleDefaultCapacity);
/**
* @js ctor
*/
ParticleBatchNode();
/**
* @js NA
* @lua NA
*/
virtual ~ParticleBatchNode();
/** initializes the particle system with Texture2D, a capacity of particles */
bool initWithTexture(Texture2D *tex, int capacity);
/** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */
bool initWithFile(const std::string& fileImage, int capacity);
/** Inserts a child into the ParticleBatchNode */
void insertChild(ParticleSystem* system, int index);
@ -128,6 +119,18 @@ public:
*/
virtual const BlendFunc& getBlendFunc(void) const override;
protected:
/**
* @js ctor
*/
ParticleBatchNode();
/** initializes the particle system with Texture2D, a capacity of particles */
bool initWithTexture(Texture2D *tex, int capacity);
/** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */
bool initWithFile(const std::string& fileImage, int capacity);
private:
void updateAllAtlasIndexes();
void increaseAtlasCapacityTo(ssize_t quantity);

View File

@ -84,12 +84,6 @@ public:
*/
void listenBackToForeground(EventCustom* event);
// Overrides
/**
* @js NA
* @lua NA
*/
virtual bool initWithTotalParticles(int numberOfParticles) override;
/**
* @js NA
* @lua NA
@ -141,6 +135,13 @@ protected:
/** initializes the texture with a rectangle measured Points */
void initTexCoordsWithRect(const Rect& rect);
// Overrides
/**
* @js NA
* @lua NA
*/
virtual bool initWithTotalParticles(int numberOfParticles) override;
void setupVBOandVAO();
void setupVBO();
bool allocMemory();

View File

@ -1553,8 +1553,7 @@ void MultipleParticleSystemsBatched::onEnter()
removeChild(_background, true);
_background = NULL;
auto batchNode = new ParticleBatchNode();
batchNode->initWithTexture(NULL, 3000);
ParticleBatchNode *batchNode = ParticleBatchNode::createWithTexture(nullptr, 3000);
addChild(batchNode, 1, 2);

View File

@ -196,24 +196,21 @@ void ParticleMainScene::createParticleSystem()
// }
// else
{
particleSystem = ParticleSystemQuad::create();
particleSystem = ParticleSystemQuad::createWithTotalParticles(quantityParticles);
}
switch( subtestNumber)
{
case 1:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
case 2:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
case 3:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
// case 4:
@ -223,21 +220,17 @@ void ParticleMainScene::createParticleSystem()
// break;
case 4:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
case 5:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
case 6:
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8);
particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
break;
// case 8:
// particleSystem->initWithTotalParticles(quantityParticles);
// ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"];
// particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
// break;
@ -247,7 +240,6 @@ void ParticleMainScene::createParticleSystem()
break;
}
addChild(particleSystem, 0, kTagParticleSystem);
particleSystem->release();
doTest();