MCPcopy Create free account
hub / github.com/axmolengine/axmol / SpriteSlice9Test7

Method SpriteSlice9Test7

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:5623–5657  ·  view source on GitHub ↗

------------------------------------------------------------------ Slice9 Test #7 ------------------------------------------------------------------

Source from the content-addressed store, hash-verified

5621//
5622//------------------------------------------------------------------
5623SpriteSlice9Test7::SpriteSlice9Test7()
5624{
5625 Size s = Director::getInstance()->getVisibleSize();
5626
5627 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini_family.plist");
5628 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini.plist");
5629
5630 // Create reference sprite that's rotating based on there anchor point
5631 auto s1 = Sprite::create("Images/grossinis_heads.png");
5632 addChild(s1);
5633 s1->getTexture()->setAliasTexParameters();
5634 s1->setTextureRect(AX_RECT_PIXELS_TO_POINTS(Rect(0, 0, 64, 128)));
5635 s1->setPosition(s.width / 2 - s.width / 3, s.height / 2);
5636 s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
5637 s1->setContentSize(Size(s.width / 3, s.height));
5638 s1->setCenterRectNormalized(Rect(0, 0, 0.5, 0.5));
5639
5640 // Create reference sprite that's rotating based on there anchor point
5641 auto s2 = Sprite::create("Images/grossinis_heads.png");
5642 addChild(s2);
5643 s2->setTextureRect(AX_RECT_PIXELS_TO_POINTS(Rect(64, 0, 64, 128)));
5644 s2->setPosition(s.width * 2 / 4, s.height / 2);
5645 s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
5646 s2->setContentSize(Size(s.width / 3, s.height));
5647 s2->setCenterRectNormalized(Rect(0.25, 0.25, 0.5, 0.5));
5648
5649 // Create reference sprite that's rotating based on there anchor point
5650 auto s3 = Sprite::create("Images/grossinis_heads.png");
5651 addChild(s3);
5652 s3->setTextureRect(AX_RECT_PIXELS_TO_POINTS(Rect(128, 0, 64, 128)));
5653 s3->setPosition(s.width / 2 + s.width / 3, s.height / 2);
5654 s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
5655 s3->setContentSize(Size(s.width / 3, s.height));
5656 s3->setCenterRectNormalized(Rect(0.5, 0.5, 0.5, 0.5));
5657}
5658
5659//------------------------------------------------------------------
5660//

Callers

nothing calls this directly

Calls 13

getInstanceFunction · 0.85
createFunction · 0.85
RectClass · 0.50
SizeFunction · 0.50
getVisibleSizeMethod · 0.45
setAliasTexParametersMethod · 0.45
getTextureMethod · 0.45
setTextureRectMethod · 0.45
setPositionMethod · 0.45
setAnchorPointMethod · 0.45

Tested by

no test coverage detected