PuzzleSDK
SpritePolygonTest1类 参考

#include <SpritePolygonTest.h>

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

Public 成员函数

 CREATE_FUNC (SpritePolygonTest1)
 
 SpritePolygonTest1 ()
 
void initSprites () override
 
- 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
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 成员函数 继承自 SpritePolygonTestDemo
virtual bool init () override
 
void initTouches ()
 
- Protected 成员函数 继承自 SpritePolygonTestCase
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
virtual void onEnter () override
 
virtual void onExit () override
 
 SpritePolygonTestCase ()
 
 ~SpritePolygonTestCase ()
 
void updateDrawNode ()
 
- Protected 属性 继承自 SpritePolygonTestDemo
cocos2d::Sprite * _polygonSprite
 
cocos2d::Sprite * _normalSprite
 
- Protected 属性 继承自 SpritePolygonTestCase
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
 

详细描述

在文件 SpritePolygonTest.h60 行定义.

构造及析构函数说明

◆ SpritePolygonTest1()

SpritePolygonTest1::SpritePolygonTest1 ( )

在文件 SpritePolygonTest.cpp169 行定义.

170{
171 _title = "SpritePolygon Creation";
172 _subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename))";
173}

引用了 SpritePolygonTestCase::_subtitle , 以及 SpritePolygonTestCase::_title.

成员函数说明

◆ CREATE_FUNC()

SpritePolygonTest1::CREATE_FUNC ( SpritePolygonTest1  )

◆ initSprites()

void SpritePolygonTest1::initSprites ( )
overridevirtual

重载 SpritePolygonTestDemo .

在文件 SpritePolygonTest.cpp175 行定义.

176{
177 auto s = Director::getInstance()->getWinSize();
178 auto offset = Vec2(0.15*s.width,0);
179 auto filename = s_pathGrossini;
180
181 //Sprite
182 auto pinfo = AutoPolygon::generatePolygon(filename);
183 _polygonSprite = Sprite::create(pinfo);
184 _polygonSprite->setTag(101);
185 addChild(_polygonSprite);
186 _polygonSprite->setPosition(Vec2(s)/2 + offset);
187
188 _normalSprite = Sprite::create(filename);
189 _normalSprite->setTag(100);
190 addChild(_normalSprite);
191 _normalSprite->setPosition(Vec2(s)/2 - offset);
192
193 //DrawNode
194 auto spDrawNode = DrawNode::create();
195 spDrawNode->setTag(_normalSprite->getTag());
196 spDrawNode->clear();
197 _normalSprite->addChild(spDrawNode);
198 _drawNodes.pushBack(spDrawNode);
199
200 auto sppDrawNode = DrawNode::create();
201 sppDrawNode->setTag(_polygonSprite->getTag());
202 sppDrawNode->clear();
203 _polygonSprite->addChild(sppDrawNode);
204 _drawNodes.pushBack(sppDrawNode);
205
206 //Label
207 TTFConfig ttfConfig("fonts/arial.ttf", 8);
208 std::string temp = "Sprite:\nPixels drawn: ";
209 auto spSize = _normalSprite->getContentSize();
210 auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
211 _normalSprite->addChild(spArea);
212 spArea->setAnchorPoint(Vec2(0,1));
213
214 temp = "SpritePolygon:\nPixels drawn: ";
215 auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
216 auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
217 _polygonSprite->addChild(sppArea);
218 sppArea->setAnchorPoint(Vec2(0,1));
219
221}
cocos2d::Vector< cocos2d::DrawNode * > _drawNodes
cocos2d::Sprite * _normalSprite
cocos2d::Sprite * _polygonSprite
static const char s_pathGrossini[]
Definition: testResource.h:28

引用了 SpritePolygonTestCase::_drawNodes, SpritePolygonTestDemo::_normalSprite, SpritePolygonTestDemo::_polygonSprite, s_pathGrossini , 以及 SpritePolygonTestCase::updateDrawNode().

+ 函数调用图:

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