2010-08-23 16:38:10 +08:00
|
|
|
#ifndef _PARTICLE_TEST_H_
|
|
|
|
#define _PARTICLE_TEST_H_
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
#include "../testBasic.h"
|
2013-06-07 08:12:28 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-04 21:58:04 +08:00
|
|
|
////----#include "cocos2d.h"
|
2013-09-03 18:22:03 +08:00
|
|
|
// #include "event_dispatcher/CCTouch.h"
|
2010-08-25 10:26:31 +08:00
|
|
|
// #include "CCParticleExample.h"
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
class ParticleTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
2013-06-07 08:12:28 +08:00
|
|
|
class ParticleDemo : public BaseTest
|
2010-08-23 16:38:10 +08:00
|
|
|
{
|
2012-04-04 21:58:04 +08:00
|
|
|
protected:
|
2013-11-15 08:21:49 +08:00
|
|
|
ParticleSystemQuad* _emitter;
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* _background;
|
|
|
|
LayerColor* _color;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
~ParticleDemo(void);
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onEnter(void);
|
2010-08-23 16:38:10 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void restartCallback(Ref* sender);
|
|
|
|
void nextCallback(Ref* sender);
|
|
|
|
void backCallback(Ref* sender);
|
|
|
|
void toggleCallback(Ref* sender);
|
2013-07-26 06:53:24 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
|
|
|
|
void onTouchesMoved(const std::vector<Touch*>& touches, Event *event);
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event *event);
|
2010-08-23 16:38:10 +08:00
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
void setEmitterPosition();
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoFirework : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoFire : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoSun : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoGalaxy : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoFlower : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoBigFlower : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoRotFlower : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoMeteor : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoSpiral : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoExplosion : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoSmoke : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoSnow : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoRain : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoModernArt : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DemoRing : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ParallaxParticle : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-23 16:38:10 +08:00
|
|
|
};
|
2010-08-26 09:55:54 +08:00
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
class DemoParticleFromFile : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-06-15 14:03:30 +08:00
|
|
|
std::string _title;
|
2012-04-04 21:58:04 +08:00
|
|
|
DemoParticleFromFile(const char *file)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_title = file;
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override
|
2012-04-04 21:58:04 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _title;
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
2010-08-26 09:55:54 +08:00
|
|
|
};
|
2010-09-25 11:54:33 +08:00
|
|
|
|
|
|
|
class RadiusMode1 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-09-25 11:54:33 +08:00
|
|
|
};
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2010-09-25 11:54:33 +08:00
|
|
|
class RadiusMode2 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2010-09-25 11:54:33 +08:00
|
|
|
class Issue704 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2010-09-25 11:54:33 +08:00
|
|
|
class Issue870 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-06-08 13:55:28 +08:00
|
|
|
void updateQuads(float dt);
|
2010-09-25 11:54:33 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
int _index;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class Issue1201 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class ParticleBatchHybrid : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2012-06-08 13:55:28 +08:00
|
|
|
void switchRender(float dt);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-22 18:29:07 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
Node* _parent1;
|
|
|
|
Node* _parent2;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class ParticleBatchMultipleEmitters : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class ParticleReorder : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2012-06-08 13:55:28 +08:00
|
|
|
void reorderParticles(float dt);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-22 18:29:07 +08:00
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _order;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class MultipleParticleSystems : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float dt);
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class MultipleParticleSystemsBatched : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void update(float dt) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-22 18:29:07 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
ParticleBatchNode* _batchNode;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class AddAndDeleteParticleSystems : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void update(float dt) override;
|
2012-06-08 13:55:28 +08:00
|
|
|
void removeSystem(float dt);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-22 18:29:07 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
ParticleBatchNode* _batchNode;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-03-22 18:29:07 +08:00
|
|
|
class ReorderParticleSystems : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2012-06-08 13:55:28 +08:00
|
|
|
void reorderSystem(float time);
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void update(float dt) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-22 18:29:07 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
ParticleBatchNode* _batchNode;
|
2012-04-04 21:58:04 +08:00
|
|
|
};
|
|
|
|
|
2012-06-12 15:40:31 +08:00
|
|
|
class PremultipliedAlphaTest : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-06-12 15:40:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class PremultipliedAlphaTest2 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-02-11 20:33:36 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Issue3990 : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-06-12 15:40:31 +08:00
|
|
|
};
|
|
|
|
|
2014-03-01 14:03:36 +08:00
|
|
|
class ParticleAutoBatching : public ParticleDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
#endif
|