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
|
|
|
|
2015-04-28 15:18:40 +08:00
|
|
|
class SpritePolygonTestCase : public TestCase
|
2015-04-23 18:03:03 +08:00
|
|
|
{
|
|
|
|
protected:
|
2015-04-24 17:39:43 +08:00
|
|
|
std::string _title;
|
|
|
|
std::string _subtitle;
|
2015-08-26 18:14:25 +08:00
|
|
|
bool _isDebugDraw;
|
|
|
|
bool _isNeedDebugMenu;
|
|
|
|
cocos2d::Vector<cocos2d::DrawNode* > _drawNodes;
|
2015-04-24 17:39:43 +08:00
|
|
|
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;
|
2015-09-16 21:49:55 +08:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-04-28 15:18:40 +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-04-28 15:18:40 +08:00
|
|
|
};
|
|
|
|
|
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);
|
2015-09-16 21:49:55 +08:00
|
|
|
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
|
|
|
|
2015-04-28 15:18:40 +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
|
|
|
|
2015-04-28 15:18:40 +08:00
|
|
|
int _posX;
|
|
|
|
int _posY;
|
|
|
|
int _leftX;
|
|
|
|
int _rightX;
|
|
|
|
bool goRight;
|
|
|
|
bool ended;
|
|
|
|
|
|
|
|
float prevDt;
|
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
unsigned int _incVert;
|
|
|
|
unsigned int _incTri;
|
|
|
|
unsigned int _incPix;
|
2015-08-26 18:14:25 +08:00
|
|
|
|
|
|
|
void updateLabel();
|
2015-09-16 21:49:55 +08:00
|
|
|
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-04-28 15:18:40 +08:00
|
|
|
};
|
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePolygonPerformanceTestDynamic : public SpritePolygonPerformance
|
2015-04-28 15:18:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-06-04 15:43:31 +08:00
|
|
|
CREATE_FUNC(SpritePolygonPerformanceTestDynamic);
|
|
|
|
SpritePolygonPerformanceTestDynamic();
|
2015-04-28 15:18:40 +08:00
|
|
|
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-04-28 15:18:40 +08:00
|
|
|
};
|
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePerformanceTestDynamic : public SpritePolygonPerformance
|
2015-04-28 15:18:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-06-04 15:43:31 +08:00
|
|
|
CREATE_FUNC(SpritePerformanceTestDynamic);
|
|
|
|
SpritePerformanceTestDynamic();
|
2015-04-28 15:18:40 +08:00
|
|
|
protected:
|
2015-08-26 18:14:25 +08:00
|
|
|
virtual cocos2d::Sprite* makeSprite() override;
|
|
|
|
virtual void initIncrementStats() override;
|
2015-04-28 15:18:40 +08:00
|
|
|
};
|
|
|
|
|
2015-04-23 18:03:03 +08:00
|
|
|
#endif /* defined(__cocos2d_tests__SpritePolygonTest__) */
|