axmol/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h

157 lines
3.9 KiB
C
Raw Normal View History

2015-04-23 18:03:03 +08:00
#ifndef __cocos2d_tests__SpritePolygonTest__
2015-06-06 13:31:25 +08:00
2015-04-23 18:03:03 +08:00
#include "../BaseTest.h"
2015-06-04 15:43:31 +08:00
#include "ui/CocosGUI.h"
2015-06-06 13:31:25 +08:00
DEFINE_TEST_SUITE(SpritePolygonTest);
2015-06-04 15:43:31 +08:00
class SpritePolygonTestCase : public TestCase
2015-04-23 18:03:03 +08:00
{
protected:
std::string _title;
std::string _subtitle;
2015-08-26 18:14:25 +08:00
bool _isDebugDraw;
bool _isNeedDebugMenu;
cocos2d::Vector<cocos2d::DrawNode* > _drawNodes;
virtual std::string title() const override {return _title;};
virtual std::string subtitle() const override {return _subtitle;};
2015-08-26 18:14:25 +08:00
virtual bool init() override;
virtual void onEnter()override;
virtual void onExit()override;
2015-08-26 18:14:25 +08:00
SpritePolygonTestCase();
~SpritePolygonTestCase();
void updateDrawNode();
2015-04-23 18:03:03 +08:00
};
class SpritePolygonTestDemo : public SpritePolygonTestCase
{
protected:
2015-08-26 18:14:25 +08:00
cocos2d::Sprite* _polygonSprite;
cocos2d::Sprite* _normalSprite;
virtual bool init() override;
virtual void initSprites(){};
void initTouches();
};
2015-06-04 15:43:31 +08:00
class SpritePolygonTest1 : public SpritePolygonTestDemo
{
public:
CREATE_FUNC(SpritePolygonTest1);
SpritePolygonTest1();
2015-08-26 18:14:25 +08:00
virtual void initSprites() override;
2015-06-04 15:43:31 +08:00
};
class SpritePolygonTest2 : public SpritePolygonTestDemo
{
public:
CREATE_FUNC(SpritePolygonTest2);
SpritePolygonTest2();
2015-08-26 18:14:25 +08:00
virtual void initSprites() override;
2015-06-04 15:43:31 +08:00
};
2015-07-31 15:49:44 +08:00
class SpritePolygonTestSlider : public SpritePolygonTestCase
{
protected:
cocos2d::Label *_epsilonLabel;
2015-08-26 18:14:25 +08:00
int _tagIndex;
2015-07-31 15:49:44 +08:00
cocos2d::Sprite* makeSprite(const std::string& filename, const cocos2d::Vec2& pos);
2015-08-26 18:14:25 +08:00
virtual bool init() override;
void initSliders();
virtual void initSprites(){};
2015-07-31 15:49:44 +08:00
void makeSprites(const std::string* list, const int count, const float y);
void changeEpsilon(Ref *pSender, cocos2d::ui::Slider::EventType type);
void updateLabel(const cocos2d::Sprite* sp, const cocos2d::PolygonInfo &pinfo);
};
class SpritePolygonTest3 : public SpritePolygonTestSlider
{
public:
CREATE_FUNC(SpritePolygonTest3);
SpritePolygonTest3();
2015-08-26 18:14:25 +08:00
void initSprites() override;
2015-07-31 15:49:44 +08:00
};
class SpritePolygonTest4 : public SpritePolygonTestSlider
{
public:
CREATE_FUNC(SpritePolygonTest4);
SpritePolygonTest4();
2015-08-26 18:14:25 +08:00
void initSprites() override;
2015-07-31 15:49:44 +08:00
};
class SpritePolygonTest5 : public SpritePolygonTestCase
{
public:
CREATE_FUNC(SpritePolygonTest5);
SpritePolygonTest5();
2015-08-26 18:14:25 +08:00
protected:
virtual bool init() override;
2015-07-31 15:49:44 +08:00
void initTouch();
void loadDefaultSprites();
void addSpritePolygon(const cocos2d::Vec2& pos);
void update(float dt)override;
2015-07-31 15:49:44 +08:00
private:
cocos2d::PolygonInfo _polygonInfo;
2015-08-26 18:14:25 +08:00
int _tagIndex;
2015-07-31 15:49:44 +08:00
};
2015-06-04 15:43:31 +08:00
class SpritePolygonPerformance : public SpritePolygonTestCase
{
public:
CREATE_FUNC(SpritePolygonPerformance);
SpritePolygonPerformance();
protected:
2015-08-26 18:14:25 +08:00
int _spriteCount;
int _vertCount;
int _triCount;
int _pixelCount;
float _elapsedTime;
cocos2d::Label * _perfLabel;
int _continuousLowDt;
float _continuousHighDtTime;
float _waitingTime;
2015-06-04 15:43:31 +08:00
int _posX;
int _posY;
int _leftX;
int _rightX;
bool goRight;
bool ended;
float prevDt;
unsigned int _incVert;
unsigned int _incTri;
unsigned int _incPix;
2015-08-26 18:14:25 +08:00
void updateLabel();
virtual void update(float dt)override;
2015-08-26 18:14:25 +08:00
virtual bool init() override;
virtual Node* makeSprite();
void incrementStats();
virtual void initIncrementStats(){};
};
2015-06-04 15:43:31 +08:00
class SpritePolygonPerformanceTestDynamic : public SpritePolygonPerformance
{
public:
2015-06-04 15:43:31 +08:00
CREATE_FUNC(SpritePolygonPerformanceTestDynamic);
SpritePolygonPerformanceTestDynamic();
protected:
2015-08-26 18:14:25 +08:00
cocos2d::Sprite* makeSprite() override;
2015-06-04 15:43:31 +08:00
cocos2d::PolygonInfo _pinfo;
2015-08-26 18:14:25 +08:00
virtual void initIncrementStats() override;
};
2015-06-04 15:43:31 +08:00
class SpritePerformanceTestDynamic : public SpritePolygonPerformance
{
public:
2015-06-04 15:43:31 +08:00
CREATE_FUNC(SpritePerformanceTestDynamic);
SpritePerformanceTestDynamic();
protected:
2015-08-26 18:14:25 +08:00
virtual cocos2d::Sprite* makeSprite() override;
virtual void initIncrementStats() override;
};
2015-04-23 18:03:03 +08:00
#endif /* defined(__cocos2d_tests__SpritePolygonTest__) */