mirror of https://github.com/axmolengine/axmol.git
parent
92fe9a33b4
commit
a6305cc1f7
|
@ -20,6 +20,7 @@ SpritePolygonTest::SpritePolygonTest()
|
|||
ADD_TEST_CASE(SpritePolygonTestTPIsland);
|
||||
ADD_TEST_CASE(SpritePolygonTestAutoPolyIsland);
|
||||
ADD_TEST_CASE(SpritePolygonTestFrameAnim);
|
||||
ADD_TEST_CASE(Issue14017Test);
|
||||
}
|
||||
|
||||
SpritePolygonTestCase::SpritePolygonTestCase()
|
||||
|
@ -781,3 +782,60 @@ void SpritePolygonTestFrameAnim::initSprites()
|
|||
sprite->runAction(RepeatForever::create(Animate::create(animation)));
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Issue14017Test
|
||||
//
|
||||
Issue14017Test::Issue14017Test()
|
||||
{
|
||||
_title = "Issue 14017";
|
||||
_subtitle = "Autopolygon around the banana";
|
||||
}
|
||||
|
||||
void Issue14017Test::initSprites()
|
||||
{
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
auto offset = Vec2(0.15*s.width,0);
|
||||
auto filename = "Images/bug14017.png";
|
||||
|
||||
//Sprite
|
||||
auto pinfo = AutoPolygon::generatePolygon(filename);
|
||||
_polygonSprite = Sprite::create(pinfo);
|
||||
_polygonSprite->setTag(101);
|
||||
addChild(_polygonSprite);
|
||||
_polygonSprite->setPosition(Vec2(s)/2 + offset);
|
||||
|
||||
_normalSprite = Sprite::create(filename);
|
||||
_normalSprite->setTag(100);
|
||||
addChild(_normalSprite);
|
||||
_normalSprite->setPosition(Vec2(s)/2 - offset);
|
||||
|
||||
//DrawNode
|
||||
auto spDrawNode = DrawNode::create();
|
||||
spDrawNode->setTag(_normalSprite->getTag());
|
||||
spDrawNode->clear();
|
||||
_normalSprite->addChild(spDrawNode);
|
||||
_drawNodes.pushBack(spDrawNode);
|
||||
|
||||
auto sppDrawNode = DrawNode::create();
|
||||
sppDrawNode->setTag(_polygonSprite->getTag());
|
||||
sppDrawNode->clear();
|
||||
_polygonSprite->addChild(sppDrawNode);
|
||||
_drawNodes.pushBack(sppDrawNode);
|
||||
|
||||
//Label
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 8);
|
||||
std::string temp = "Sprite:\nPixels drawn: ";
|
||||
auto spSize = _normalSprite->getContentSize();
|
||||
auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString());
|
||||
_normalSprite->addChild(spArea);
|
||||
spArea->setAnchorPoint(Vec2(0,1));
|
||||
|
||||
temp = "SpritePolygon:\nPixels drawn: ";
|
||||
auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString();
|
||||
auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount);
|
||||
_polygonSprite->addChild(sppArea);
|
||||
sppArea->setAnchorPoint(Vec2(0,1));
|
||||
|
||||
updateDrawNode();
|
||||
}
|
||||
|
|
|
@ -185,4 +185,12 @@ public:
|
|||
virtual void initSprites() override;
|
||||
};
|
||||
|
||||
class Issue14017Test : public SpritePolygonTestDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Issue14017Test);
|
||||
Issue14017Test();
|
||||
virtual void initSprites() override;
|
||||
};
|
||||
|
||||
#endif /* defined(__cocos2d_tests__SpritePolygonTest__) */
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Loading…
Reference in New Issue