#include <ParticleTest.h>
◆ CREATE_FUNC()
◆ onEnter()
| void AddAndDeleteParticleSystems::onEnter |
( |
| ) |
|
|
overridevirtual |
重载 ParticleDemo .
在文件 ParticleTest.cpp 第 1610 行定义.
1614 _color->setColor(Color3B::BLACK);
1619 _batchNode = ParticleBatchNode::createWithTexture((Texture2D*)
nullptr, 16000);
1623 for (
int i = 0; i<6; i++) {
1625 auto particleSystem = ParticleSystemQuad::create(
"Particles/Spiral.plist");
1626 _batchNode->setTexture(particleSystem->getTexture());
1628 particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED);
1629 particleSystem->setTotalParticles(200);
1631 particleSystem->setPosition(Vec2(i*15 +100.0f,i*15+100.0f));
1633 unsigned int randZ = rand() % 100;
1634 _batchNode->addChild(particleSystem, randZ, -1);
cocos2d::ParticleBatchNode * _batchNode
void removeSystem(float dt)
cocos2d::Sprite * _background
virtual void onEnter() override
cocos2d::ParticleSystemQuad * _emitter
cocos2d::LayerColor * _color
引用了 ParticleDemo::_background, _batchNode, ParticleDemo::_color, ParticleDemo::_emitter, ParticleDemo::onEnter() , 以及 removeSystem().
◆ removeSystem()
| void AddAndDeleteParticleSystems::removeSystem |
( |
float |
dt | ) |
|
在文件 ParticleTest.cpp 第 1643 行定义.
1645 ssize_t nChildrenCount =
_batchNode->getChildren().size();
1646 if (nChildrenCount > 0)
1648 CCLOG(
"remove random system");
1649 unsigned int uRand = rand() % (nChildrenCount - 1);
1652 auto particleSystem = ParticleSystemQuad::create(
"Particles/Spiral.plist");
1655 particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED);
1656 particleSystem->setTotalParticles(200);
1658 particleSystem->setPosition(Vec2(rand() % 300 ,rand() % 400));
1660 CCLOG(
"add a new system");
1661 unsigned int randZ = rand() % 100;
1662 _batchNode->addChild(particleSystem, randZ, -1);
引用了 _batchNode.
被这些函数引用 onEnter().
◆ subtitle()
| std::string AddAndDeleteParticleSystems::subtitle |
( |
| ) |
const |
|
overridevirtual |
◆ title()
| std::string AddAndDeleteParticleSystems::title |
( |
| ) |
const |
|
overridevirtual |
◆ update()
| void AddAndDeleteParticleSystems::update |
( |
float |
dt | ) |
|
|
overridevirtual |
重载 ParticleDemo .
在文件 ParticleTest.cpp 第 1666 行定义.
1672 auto batchNode = getChildByTag(2);
1673 for(
const auto &child : batchNode->getChildren()) {
1674 auto item =
dynamic_cast<ParticleSystem*
>(child);
1675 if (item !=
nullptr)
1677 count += item->getParticleCount();
1681 char str[100] = {0};
1682 sprintf(str,
"%4d", count);
1683 atlas->setString(str);
引用了 kTagParticleCount.
◆ _batchNode
| cocos2d::ParticleBatchNode* AddAndDeleteParticleSystems::_batchNode |
|
private |
该类的文档由以下文件生成:
- /Users/yujizhu/Documents/Git/cocos2d-x-4.0/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h
- /Users/yujizhu/Documents/Git/cocos2d-x-4.0/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp