PuzzleSDK
SpritePolygonTestCase类 参考

#include <SpritePolygonTest.h>

+ 类 SpritePolygonTestCase 继承关系图:
+ SpritePolygonTestCase 的协作图:

Protected 成员函数

virtual std::string title () const override
 
virtual std::string subtitle () const override
 
virtual bool init () override
 
virtual void onEnter () override
 
virtual void onExit () override
 
 SpritePolygonTestCase ()
 
 ~SpritePolygonTestCase ()
 
void updateDrawNode ()
 

Protected 属性

std::string _title
 
std::string _subtitle
 
bool _isDebugDraw
 
bool _isNeedDebugMenu
 
cocos2d::Vector< cocos2d::DrawNode * > _drawNodes
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 SpritePolygonTest.h32 行定义.

构造及析构函数说明

◆ SpritePolygonTestCase()

SpritePolygonTestCase::SpritePolygonTestCase ( )
protected

在文件 SpritePolygonTest.cpp47 行定义.

引用了 _isDebugDraw , 以及 _isNeedDebugMenu.

◆ ~SpritePolygonTestCase()

SpritePolygonTestCase::~SpritePolygonTestCase ( )
protected

在文件 SpritePolygonTest.cpp53 行定义.

54{
55 _drawNodes.clear();
56}
cocos2d::Vector< cocos2d::DrawNode * > _drawNodes

引用了 _drawNodes.

成员函数说明

◆ init()

bool SpritePolygonTestCase::init ( )
overrideprotectedvirtual

SpritePolygonTestDemo, SpritePolygonTestSlider, SpritePolygonTest5 , 以及 SpritePolygonPerformance 重载.

在文件 SpritePolygonTest.cpp70 行定义.

71{
72 if(TestCase::init())
73 {
75 {
76 TTFConfig ttfConfig("fonts/arial.ttf", 10);
77 auto label = Label::createWithTTF(ttfConfig,"DebugDraw OFF");
78 auto menuItem = MenuItemLabel::create(label, [=](Ref *ref){
79 if (_isDebugDraw){
80 _isDebugDraw = false;
81 label->setString("DebugDraw ON");
82 for (int i = 0; i < _drawNodes.size(); i++)
83 {
84 _drawNodes.at(i)->setVisible(false);
85 }
86 }else{
87 _isDebugDraw = true;
88 label->setString("DebugDraw OFF");
89 for (int i = 0; i < _drawNodes.size(); i++)
90 {
91 _drawNodes.at(i)->setVisible(true);
93 }
94 }
95 });
96
97 auto menu = Menu::create(menuItem, nullptr);
98 menu->setPosition(Vec2::ZERO);
99 menuItem->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
100 menuItem->setPosition( VisibleRect::leftBottom() + Vec2(0.0f, VisibleRect::leftTop().y/4));
101 this->addChild(menu, 9999);
102 }
103 return true;
104 }
105 return false;
106}
static cocos2d::Vec2 leftTop()
Definition: VisibleRect.cpp:75
static cocos2d::Vec2 leftBottom()
Definition: VisibleRect.cpp:87

引用了 _drawNodes, _isDebugDraw, _isNeedDebugMenu, VisibleRect::leftBottom(), VisibleRect::leftTop() , 以及 updateDrawNode().

被这些函数引用 SpritePolygonTestDemo::init(), SpritePolygonTestSlider::init(), SpritePolygonTest5::init() , 以及 SpritePolygonPerformance::init().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ onEnter()

void SpritePolygonTestCase::onEnter ( )
overrideprotectedvirtual

重载 TestCase .

在文件 SpritePolygonTest.cpp58 行定义.

59{
61 Director::getInstance()->setClearColor(Color4F(102.0f/255.0f, 184.0f/255.0f, 204.0f/255.0f, 1.0f));
62}
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 TestCase::onEnter().

+ 函数调用图:

◆ onExit()

void SpritePolygonTestCase::onExit ( )
overrideprotectedvirtual

在文件 SpritePolygonTest.cpp64 行定义.

65{
66 Director::getInstance()->setClearColor(Color4F::BLACK);
67 TestCase::onExit();
68}

◆ subtitle()

virtual std::string SpritePolygonTestCase::subtitle ( ) const
inlineoverrideprotectedvirtual

重载 TestCase .

在文件 SpritePolygonTest.h41 行定义.

41{return _subtitle;};

引用了 _subtitle.

◆ title()

virtual std::string SpritePolygonTestCase::title ( ) const
inlineoverrideprotectedvirtual

重载 TestCase .

在文件 SpritePolygonTest.h40 行定义.

40{return _title;};

引用了 _title.

◆ updateDrawNode()

void SpritePolygonTestCase::updateDrawNode ( )
protected

在文件 SpritePolygonTest.cpp108 行定义.

109{
110 if (_isDebugDraw && _drawNodes.size() > 0) {
111 for (int i = 0; i < _drawNodes.size(); i++)
112 {
113 auto drawnode = _drawNodes.at(i);
114 auto sp = (Sprite*)drawnode->getParent();
115 if(!sp) return;
116 const auto& polygoninfo = sp->getPolygonInfo();
117 drawnode->clear();
118 const auto count = polygoninfo.triangles.indexCount/3;
119 const auto indices = polygoninfo.triangles.indices;
120 const auto verts = polygoninfo.triangles.verts;
121 for(ssize_t i = 0; i < count; i++)
122 {
123 //draw 3 lines
124 Vec3 from = verts[indices[i*3]].vertices;
125 Vec3 to = verts[indices[i*3+1]].vertices;
126 drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
127
128 from = verts[indices[i*3+1]].vertices;
129 to = verts[indices[i*3+2]].vertices;
130 drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
131
132 from = verts[indices[i*3+2]].vertices;
133 to = verts[indices[i*3]].vertices;
134 drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
135 }
136 }
137 }
138}

引用了 _drawNodes , 以及 _isDebugDraw.

被这些函数引用 SpritePolygonTestSlider::changeEpsilon(), init(), SpritePolygonTest1::initSprites(), SpritePolygonTest2::initSprites(), SpritePolygonTestNoCrash::initSprites(), SpritePolygonTestTPIsland::initSprites(), SpritePolygonTestAutoPolyIsland::initSprites(), SpritePolygonTestFrameAnim::initSprites(), Issue14017Test::initSprites(), SpritePolygonTestDemo::initTouches(), SpritePolygonTest5::loadDefaultSprites(), SpritePolygonTestSlider::makeSprite() , 以及 SpritePolygonTest5::update().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _drawNodes

◆ _isDebugDraw

bool SpritePolygonTestCase::_isDebugDraw
protected

在文件 SpritePolygonTest.h37 行定义.

被这些函数引用 init(), SpritePolygonTestCase() , 以及 updateDrawNode().

◆ _isNeedDebugMenu

bool SpritePolygonTestCase::_isNeedDebugMenu
protected

◆ _subtitle

◆ _title


该类的文档由以下文件生成: