mirror of https://github.com/axmolengine/axmol.git
141 lines
3.3 KiB
C++
141 lines
3.3 KiB
C++
#ifndef __cocos2d_tests__SpritePolygonTest__
|
|
|
|
#include "../BaseTest.h"
|
|
#include "ui/CocosGUI.h"
|
|
|
|
DEFINE_TEST_SUITE(SpritePolygonTest);
|
|
|
|
class SpritePolygonTestCase : public TestCase
|
|
{
|
|
protected:
|
|
virtual void onBackCallback(Ref* sender)override;
|
|
std::string _title;
|
|
std::string _subtitle;
|
|
virtual std::string title() const override {return _title;};
|
|
virtual std::string subtitle() const override {return _subtitle;};
|
|
};
|
|
|
|
class SpritePolygonTestDemo : public SpritePolygonTestCase
|
|
{
|
|
protected:
|
|
void initTouchDebugDraw();
|
|
cocos2d::Sprite* spp;
|
|
cocos2d::Sprite* sp;
|
|
};
|
|
|
|
class SpritePolygonTest1 : public SpritePolygonTestDemo
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTest1);
|
|
SpritePolygonTest1();
|
|
void make2Sprites();
|
|
};
|
|
|
|
class SpritePolygonTest2 : public SpritePolygonTestDemo
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTest2);
|
|
SpritePolygonTest2();
|
|
void make2Sprites();
|
|
};
|
|
|
|
class SpritePolygonTestSlider : public SpritePolygonTestCase
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTestSlider);
|
|
SpritePolygonTestSlider();
|
|
protected:
|
|
cocos2d::Label *_epsilonLabel;
|
|
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);
|
|
};
|
|
|
|
class SpritePolygonTest3 : public SpritePolygonTestSlider
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTest3);
|
|
SpritePolygonTest3();
|
|
};
|
|
|
|
class SpritePolygonTest4 : public SpritePolygonTestSlider
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTest4);
|
|
SpritePolygonTest4();
|
|
};
|
|
|
|
class SpritePolygonTest5 : public SpritePolygonTestCase
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonTest5);
|
|
SpritePolygonTest5();
|
|
void initTouch();
|
|
void loadDefaultSprites();
|
|
void addSpritePolygon(const cocos2d::Vec2& pos);
|
|
private:
|
|
cocos2d::PolygonInfo _polygonInfo;
|
|
};
|
|
|
|
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;
|
|
|
|
|
|
int _posX;
|
|
int _posY;
|
|
int _leftX;
|
|
int _rightX;
|
|
bool goRight;
|
|
bool ended;
|
|
|
|
float prevDt;
|
|
|
|
virtual Node* makeSprite();
|
|
virtual void incrementStats();
|
|
|
|
void initIncrementStats();
|
|
unsigned int _incVert;
|
|
unsigned int _incTri;
|
|
unsigned int _incPix;
|
|
};
|
|
|
|
class SpritePolygonPerformanceTestDynamic : public SpritePolygonPerformance
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePolygonPerformanceTestDynamic);
|
|
SpritePolygonPerformanceTestDynamic();
|
|
protected:
|
|
cocos2d::Sprite* makeSprite();
|
|
cocos2d::PolygonInfo _pinfo;
|
|
void initIncrementStats();
|
|
};
|
|
|
|
class SpritePerformanceTestDynamic : public SpritePolygonPerformance
|
|
{
|
|
public:
|
|
CREATE_FUNC(SpritePerformanceTestDynamic);
|
|
SpritePerformanceTestDynamic();
|
|
protected:
|
|
cocos2d::Sprite* makeSprite();
|
|
void initIncrementStats();
|
|
};
|
|
|
|
#endif /* defined(__cocos2d_tests__SpritePolygonTest__) */
|