PuzzleSDK
ReorderParticleSystems类 参考

#include <ParticleTest.h>

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

Public 成员函数

 CREATE_FUNC (ReorderParticleSystems)
 
virtual void onEnter () override
 
void reorderSystem (float time)
 
virtual void update (float dt) override
 
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.h329 行定义.

成员函数说明

◆ CREATE_FUNC()

ReorderParticleSystems::CREATE_FUNC ( ReorderParticleSystems  )

◆ onEnter()

void ReorderParticleSystems::onEnter ( )
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1698 行定义.

1699{
1701
1702 _color->setColor(Color3B::BLACK);
1703 removeChild(_background ,true);
1704 _background = nullptr;
1705
1706 _batchNode = ParticleBatchNode::create("Images/stars-grayscale.png" ,3000);
1707
1708 addChild(_batchNode, 1, 2);
1709
1710
1711 for (int i = 0; i<3; i++) {
1712
1713 auto particleSystem = ParticleSystemQuad::createWithTotalParticles(200);
1714 particleSystem->retain();
1715 particleSystem->setTexture(_batchNode->getTexture());
1716
1717 // duration
1718 particleSystem->setDuration(ParticleSystem::DURATION_INFINITY);
1719
1720 // radius mode
1721 particleSystem->setEmitterMode(ParticleSystem::Mode::RADIUS);
1722
1723 // radius mode: 100 pixels from center
1724 particleSystem->setStartRadius(100);
1725 particleSystem->setStartRadiusVar(0);
1726 particleSystem->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
1727 particleSystem->setEndRadiusVar(0); // not used when start == end
1728
1729 // radius mode: degrees per second
1730 // 45 * 4 seconds of life = 180 degrees
1731 particleSystem->setRotatePerSecond(45);
1732 particleSystem->setRotatePerSecondVar(0);
1733
1734
1735 // angle
1736 particleSystem->setAngle(90);
1737 particleSystem->setAngleVar(0);
1738
1739 // emitter position
1740 particleSystem->setPosVar(Vec2::ZERO);
1741
1742 // life of particles
1743 particleSystem->setLife(4);
1744 particleSystem->setLifeVar(0);
1745
1746 // spin of particles
1747 particleSystem->setStartSpin(0);
1748 particleSystem->setStartSpinVar(0);
1749 particleSystem->setEndSpin(0);
1750 particleSystem->setEndSpinVar(0);
1751
1752 // color of particles
1753 float color[3] = {0,0,0};
1754 color[i] = 1;
1755 Color4F startColor(color[0], color[1], color[2], 1.0f);
1756 particleSystem->setStartColor(startColor);
1757
1758 Color4F startColorVar(0, 0, 0, 0);
1759 particleSystem->setStartColorVar(startColorVar);
1760
1761 Color4F endColor = startColor;
1762 particleSystem->setEndColor(endColor);
1763
1764 Color4F endColorVar = startColorVar;
1765 particleSystem->setEndColorVar(endColorVar);
1766
1767 // size, in pixels
1768 particleSystem->setStartSize(32);
1769 particleSystem->setStartSizeVar(0);
1770 particleSystem->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
1771
1772 // emits per second
1773 particleSystem->setEmissionRate(particleSystem->getTotalParticles()/particleSystem->getLife());
1774
1775 // additive
1776
1777 particleSystem->setPosition(Vec2(i*10+120.0f,200.0f));
1778
1779
1780 _batchNode->addChild(particleSystem);
1781 particleSystem->setPositionType(ParticleSystem::PositionType::FREE);
1782
1783 particleSystem->release();
1784
1785 //[pBNode addChild:particleSystem z:10 tag:0);
1786
1787 }
1788
1789 schedule(CC_SCHEDULE_SELECTOR(ReorderParticleSystems::reorderSystem), 2.0f);
1790 _emitter = nullptr;
1791
1792}
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
void reorderSystem(float time)
cocos2d::ParticleBatchNode * _batchNode
Definition: ParticleTest.h:339

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

+ 函数调用图:

◆ reorderSystem()

void ReorderParticleSystems::reorderSystem ( float  time)

在文件 ParticleTest.cpp1794 行定义.

1795{
1796 auto system = static_cast<ParticleSystem*>(_batchNode->getChildren().at(1));
1797 _batchNode->reorderChild(system, system->getLocalZOrder() - 1);
1798}

引用了 _batchNode.

被这些函数引用 onEnter().

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

◆ subtitle()

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

重载 ParticleDemo .

在文件 ParticleTest.cpp1825 行定义.

1826{
1827 return "changes every 2 seconds";
1828}

◆ title()

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

重载 ParticleDemo .

在文件 ParticleTest.cpp1820 行定义.

1821{
1822 return "reorder systems";
1823}

◆ update()

void ReorderParticleSystems::update ( float  dt)
overridevirtual

重载 ParticleDemo .

在文件 ParticleTest.cpp1801 行定义.

1802{
1803 auto atlas = static_cast<LabelAtlas*>(getChildByTag(kTagParticleCount));
1804
1805 int count = 0;
1806
1807 auto batchNode = getChildByTag(2);
1808 for(const auto &child : batchNode->getChildren()) {
1809 auto item = dynamic_cast<ParticleSystem*>(child);
1810 if (item != nullptr)
1811 {
1812 count += item->getParticleCount();
1813 }
1814 }
1815 char str[100] = {0};
1816 sprintf(str, "%4d", count);
1817 atlas->setString(str);
1818}
@ kTagParticleCount

引用了 kTagParticleCount.

类成员变量说明

◆ _batchNode

cocos2d::ParticleBatchNode* ReorderParticleSystems::_batchNode
private

在文件 ParticleTest.h339 行定义.

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


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