PuzzleSDK
Issue14017Test类 参考

#include <SpritePolygonTest.h>

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

Public 成员函数

 CREATE_FUNC (Issue14017Test)
 
 Issue14017Test ()
 
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.h212 行定义.

构造及析构函数说明

◆ Issue14017Test()

Issue14017Test::Issue14017Test ( )

在文件 SpritePolygonTest.cpp811 行定义.

812{
813 _title = "Issue 14017";
814 _subtitle = "Autopolygon around the banana";
815}

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

成员函数说明

◆ CREATE_FUNC()

Issue14017Test::CREATE_FUNC ( Issue14017Test  )

◆ initSprites()

void Issue14017Test::initSprites ( )
overridevirtual

重载 SpritePolygonTestDemo .

在文件 SpritePolygonTest.cpp817 行定义.

818{
819 auto s = Director::getInstance()->getWinSize();
820 auto offset = Vec2(0.15*s.width,0);
821 auto filename = "Images/bug14017.png";
822
823 //Sprite
824 auto pinfo = AutoPolygon::generatePolygon(filename);
825 _polygonSprite = Sprite::create(pinfo);
826 _polygonSprite->setTag(101);
827 addChild(_polygonSprite);
828 _polygonSprite->setPosition(Vec2(s)/2 + offset);
829
830 _normalSprite = Sprite::create(filename);
831 _normalSprite->setTag(100);
832 addChild(_normalSprite);
833 _normalSprite->setPosition(Vec2(s)/2 - offset);
834
835 //DrawNode
836 auto spDrawNode = DrawNode::create();
837 spDrawNode->setTag(_normalSprite->getTag());
838 spDrawNode->clear();
839 _normalSprite->addChild(spDrawNode);
840 _drawNodes.pushBack(spDrawNode);
841
842 auto sppDrawNode = DrawNode::create();
843 sppDrawNode->setTag(_polygonSprite->getTag());
844 sppDrawNode->clear();
845 _polygonSprite->addChild(sppDrawNode);
846 _drawNodes.pushBack(sppDrawNode);
847
848 //Label
849 TTFConfig ttfConfig("fonts/arial.ttf", 8);
850 std::string temp = "Sprite:\nPixels drawn: ";
851 auto spSize = _normalSprite->getContentSize();
852 auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
853 _normalSprite->addChild(spArea);
854 spArea->setAnchorPoint(Vec2(0,1));
855
856 temp = "SpritePolygon:\nPixels drawn: ";
857 auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
858 auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
859 _polygonSprite->addChild(sppArea);
860 sppArea->setAnchorPoint(Vec2(0,1));
861
863}
cocos2d::Vector< cocos2d::DrawNode * > _drawNodes
cocos2d::Sprite * _normalSprite
cocos2d::Sprite * _polygonSprite

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

+ 函数调用图:

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