PuzzleSDK
SpritePolygonTest2类 参考

#include <SpritePolygonTest.h>

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

Public 成员函数

 CREATE_FUNC (SpritePolygonTest2)
 
 SpritePolygonTest2 ()
 
virtual 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.h68 行定义.

构造及析构函数说明

◆ SpritePolygonTest2()

SpritePolygonTest2::SpritePolygonTest2 ( )

在文件 SpritePolygonTest.cpp223 行定义.

224{
225 _title = "SpritePolygon Creation with a rect";
226 _subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename, rect))";
227}

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

成员函数说明

◆ CREATE_FUNC()

SpritePolygonTest2::CREATE_FUNC ( SpritePolygonTest2  )

◆ initSprites()

void SpritePolygonTest2::initSprites ( )
overridevirtual

重载 SpritePolygonTestDemo .

在文件 SpritePolygonTest.cpp229 行定义.

230{
231 auto s = Director::getInstance()->getWinSize();
232 auto offset = Vec2(0.15*s.width,0);
233 auto filename = s_pathGrossini;
234 Rect head = Rect(30,25,25,25);
235
236 //Sprite
237 auto pinfo = AutoPolygon::generatePolygon(filename, head);
238 _polygonSprite = Sprite::create(pinfo);
239 _polygonSprite->setTag(101);
240 addChild(_polygonSprite);
241 _polygonSprite->setPosition(Vec2(s)/2 + offset);
242
243 _normalSprite = Sprite::create(filename,head);
244 _normalSprite->setTag(100);
245 addChild(_normalSprite);
246 _normalSprite->setPosition(Vec2(s)/2 - offset);
247
248 //DrawNode
249 auto spDrawNode = DrawNode::create();
250 _drawNodes.pushBack(spDrawNode);
251 spDrawNode->setTag(_normalSprite->getTag());
252 spDrawNode->clear();
253 _normalSprite->addChild(spDrawNode);
254
255 auto sppDrawNode = DrawNode::create();
256 _drawNodes.pushBack(sppDrawNode);
257 sppDrawNode->setTag(_polygonSprite->getTag());
258 sppDrawNode->clear();
259 _polygonSprite->addChild(sppDrawNode);
260
261 //Label
262 TTFConfig ttfConfig("fonts/arial.ttf", 8);
263 std::string temp = "Sprite:\nPixels drawn: ";
264 auto spSize = _normalSprite->getContentSize();
265 auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
266 _normalSprite->addChild(spArea);
267 spArea->setAnchorPoint(Vec2(0,1));
268
269 temp = "SpritePolygon:\nPixels drawn: ";
270 auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
271 auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
272 _polygonSprite->addChild(sppArea);
273 sppArea->setAnchorPoint(Vec2(0,1));
274
276}
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().

+ 函数调用图:

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