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-07-15 12:04:48 +08:00
|
|
|
virtual void onBackCallback(Ref* sender)override;
|
2015-04-24 17:39:43 +08:00
|
|
|
std::string _title;
|
|
|
|
std::string _subtitle;
|
|
|
|
virtual std::string title() const override {return _title;};
|
|
|
|
virtual std::string subtitle() const override {return _subtitle;};
|
2015-04-23 18:03:03 +08:00
|
|
|
};
|
|
|
|
|
2015-04-28 15:18:40 +08:00
|
|
|
class SpritePolygonTestDemo : public SpritePolygonTestCase
|
|
|
|
{
|
|
|
|
protected:
|
2015-06-04 15:43:31 +08:00
|
|
|
void initTouchDebugDraw();
|
|
|
|
cocos2d::Sprite* spp;
|
2015-04-28 15:18:40 +08:00
|
|
|
cocos2d::Sprite* sp;
|
|
|
|
};
|
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePolygonTest1 : public SpritePolygonTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpritePolygonTest1);
|
|
|
|
SpritePolygonTest1();
|
|
|
|
void make2Sprites();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpritePolygonTest2 : public SpritePolygonTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpritePolygonTest2);
|
|
|
|
SpritePolygonTest2();
|
|
|
|
void make2Sprites();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-28 15:18:40 +08:00
|
|
|
class SpritePolygonPerformance : public SpritePolygonTestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpritePolygonPerformance);
|
|
|
|
SpritePolygonPerformance();
|
|
|
|
virtual void update(float dt);
|
|
|
|
protected:
|
|
|
|
int spriteCount;
|
|
|
|
int vertCount;
|
|
|
|
int triCount;
|
|
|
|
int pixelCount;
|
|
|
|
float elapsedTime;
|
|
|
|
cocos2d::Label * perfLabel;
|
|
|
|
void updateLabel();
|
|
|
|
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;
|
|
|
|
|
|
|
|
virtual Node* makeSprite();
|
|
|
|
virtual void incrementStats();
|
|
|
|
|
|
|
|
void initIncrementStats();
|
2015-06-11 14:38:38 +08:00
|
|
|
unsigned int _incVert;
|
|
|
|
unsigned int _incTri;
|
|
|
|
unsigned int _incPix;
|
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-06-04 15:43:31 +08:00
|
|
|
cocos2d::Sprite* makeSprite();
|
|
|
|
cocos2d::PolygonInfo _pinfo;
|
2015-04-28 15:18:40 +08:00
|
|
|
void initIncrementStats();
|
|
|
|
};
|
|
|
|
|
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:
|
|
|
|
cocos2d::Sprite* makeSprite();
|
|
|
|
void initIncrementStats();
|
|
|
|
};
|
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePolygonTestSlider : public SpritePolygonTestCase
|
2015-04-28 15:18:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-06-04 15:43:31 +08:00
|
|
|
CREATE_FUNC(SpritePolygonTestSlider);
|
|
|
|
SpritePolygonTestSlider();
|
2015-04-28 15:18:40 +08:00
|
|
|
protected:
|
2015-06-08 15:08:16 +08:00
|
|
|
cocos2d::Label *_epsilonLabel;
|
2015-06-04 15:43:31 +08:00
|
|
|
cocos2d::Sprite* makeSprite(const std::string& filename, const cocos2d::Vec2& pos);
|
|
|
|
void makeSprites(const std::string* list, const int count, const float y);
|
|
|
|
cocos2d::TTFConfig _ttfConfig;
|
|
|
|
void changeEpsilon(Ref *pSender, cocos2d::ui::Slider::EventType type);
|
|
|
|
void updateLabel(const cocos2d::Sprite* sp, const cocos2d::PolygonInfo &pinfo);
|
2015-04-28 15:18:40 +08:00
|
|
|
};
|
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePolygonTest3 : public SpritePolygonTestSlider
|
2015-04-28 15:18:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-06-04 15:43:31 +08:00
|
|
|
CREATE_FUNC(SpritePolygonTest3);
|
|
|
|
SpritePolygonTest3();
|
2015-04-28 15:18:40 +08:00
|
|
|
};
|
2015-06-04 15:43:31 +08:00
|
|
|
class SpritePolygonTest4 : public SpritePolygonTestSlider
|
2015-06-02 10:10:09 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpritePolygonTest4);
|
|
|
|
SpritePolygonTest4();
|
|
|
|
};
|
2015-04-27 13:34:47 +08:00
|
|
|
|
2015-06-04 15:43:31 +08:00
|
|
|
|
2015-04-23 18:03:03 +08:00
|
|
|
#endif /* defined(__cocos2d_tests__SpritePolygonTest__) */
|