PuzzleSDK
AddAndDeleteParticleSystems类 参考

#include <ParticleTest.h>

+ 类 AddAndDeleteParticleSystems 继承关系图:
+ AddAndDeleteParticleSystems 的协作图:

Public 成员函数

 CREATE_FUNC (AddAndDeleteParticleSystems)
 
virtual void onEnter () override
 
virtual void update (float dt) override
 
void removeSystem (float dt)
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 ParticleDemo
 ~ParticleDemo ()
 
void toggleCallback (cocos2d::Ref *sender)
 
void onTouchesBegan (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void onTouchesMoved (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void onTouchesEnded (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void setEmitterPosition ()
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Private 属性

cocos2d::ParticleBatchNode * _batchNode
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 ParticleDemo
cocos2d::ParticleSystemQuad * _emitter
 
cocos2d::Sprite * _background
 
cocos2d::LayerColor * _color
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 ParticleTest.h316 行定义.

成员函数说明

◆ CREATE_FUNC()

AddAndDeleteParticleSystems::CREATE_FUNC ( AddAndDeleteParticleSystems  )

◆ onEnter()

void AddAndDeleteParticleSystems::onEnter ( )
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1610 行定义.

1611{
1613
1614 _color->setColor(Color3B::BLACK);
1615 removeChild(_background, true);
1616 _background = nullptr;
1617
1618 //adds the texture inside the plist to the texture cache
1619 _batchNode = ParticleBatchNode::createWithTexture((Texture2D*)nullptr, 16000);
1620
1621 addChild(_batchNode, 1, 2);
1622
1623 for (int i = 0; i<6; i++) {
1624
1625 auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
1626 _batchNode->setTexture(particleSystem->getTexture());
1627
1628 particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED);
1629 particleSystem->setTotalParticles(200);
1630
1631 particleSystem->setPosition(Vec2(i*15 +100.0f,i*15+100.0f));
1632
1633 unsigned int randZ = rand() % 100;
1634 _batchNode->addChild(particleSystem, randZ, -1);
1635
1636 }
1637
1638 schedule(CC_SCHEDULE_SELECTOR(AddAndDeleteParticleSystems::removeSystem), 0.5f);
1639 _emitter = nullptr;
1640
1641}
cocos2d::ParticleBatchNode * _batchNode
Definition: ParticleTest.h:326
cocos2d::Sprite * _background
Definition: ParticleTest.h:36
virtual void onEnter() override
cocos2d::ParticleSystemQuad * _emitter
Definition: ParticleTest.h:35
cocos2d::LayerColor * _color
Definition: ParticleTest.h:37

引用了 ParticleDemo::_background, _batchNode, ParticleDemo::_color, ParticleDemo::_emitter, ParticleDemo::onEnter() , 以及 removeSystem().

+ 函数调用图:

◆ removeSystem()

void AddAndDeleteParticleSystems::removeSystem ( float  dt)

在文件 ParticleTest.cpp1643 行定义.

1644{
1645 ssize_t nChildrenCount = _batchNode->getChildren().size();
1646 if (nChildrenCount > 0)
1647 {
1648 CCLOG("remove random system");
1649 unsigned int uRand = rand() % (nChildrenCount - 1);
1650 _batchNode->removeChild(_batchNode->getChildren().at(uRand), true);
1651
1652 auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
1653 //add new
1654
1655 particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED);
1656 particleSystem->setTotalParticles(200);
1657
1658 particleSystem->setPosition(Vec2(rand() % 300 ,rand() % 400));
1659
1660 CCLOG("add a new system");
1661 unsigned int randZ = rand() % 100;
1662 _batchNode->addChild(particleSystem, randZ, -1);
1663 }
1664}

引用了 _batchNode.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

◆ subtitle()

std::string AddAndDeleteParticleSystems::subtitle ( ) const
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1691 行定义.

1692{
1693 return "v1.1 test: every 2 sec 1 system disappear, 1 appears";
1694}

◆ title()

std::string AddAndDeleteParticleSystems::title ( ) const
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1686 行定义.

1687{
1688 return "Add and remove Particle System";
1689}

◆ update()

void AddAndDeleteParticleSystems::update ( float  dt)
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1666 行定义.

1667{
1668 auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount);
1669
1670 int count = 0;
1671
1672 auto batchNode = getChildByTag(2);
1673 for(const auto &child : batchNode->getChildren()) {
1674 auto item = dynamic_cast<ParticleSystem*>(child);
1675 if (item != nullptr)
1676 {
1677 count += item->getParticleCount();
1678 }
1679 }
1680
1681 char str[100] = {0};
1682 sprintf(str, "%4d", count);
1683 atlas->setString(str);
1684}
@ kTagParticleCount

引用了 kTagParticleCount.

类成员变量说明

◆ _batchNode

cocos2d::ParticleBatchNode* AddAndDeleteParticleSystems::_batchNode
private

在文件 ParticleTest.h326 行定义.

被这些函数引用 onEnter() , 以及 removeSystem().


该类的文档由以下文件生成: