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

Method SpriteSlice9Test1

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:5212–5270  ·  view source on GitHub ↗

------------------------------------------------------------------ Slice9 Test #1 ------------------------------------------------------------------

Source from the content-addressed store, hash-verified

5210//
5211//------------------------------------------------------------------
5212SpriteSlice9Test1::SpriteSlice9Test1()
5213{
5214 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini_family.plist");
5215 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini.plist");
5216
5217 Size s = Director::getInstance()->getWinSize();
5218
5219 for (int i = 2; i > 0; --i)
5220 {
5221 auto s1 = Sprite::create("Images/grossinis_sister1.png");
5222 addChild(s1);
5223 s1->setPosition(s.width * 1 / 4, s.height * i / 3);
5224 s1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
5225 s1->setContentSize(Size(s1->getContentSize().width, 200.0f));
5226 auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f));
5227 s1->runAction(action1);
5228
5229 // Create reference sprite that's rotating based on there anchor point
5230 auto s2 = Sprite::create("Images/grossinis_sister1.png");
5231 addChild(s2);
5232 s2->setPosition(s.width * 2 / 4, s.height * i / 3);
5233 s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
5234 s2->setContentSize(Size(s2->getContentSize().width, 200.0f));
5235 auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f));
5236 s2->runAction(action2);
5237
5238 // Create reference sprite that's rotating based on there anchor point
5239 auto s3 = Sprite::create("Images/grossinis_sister1.png");
5240 addChild(s3);
5241 s3->setPosition(s.width * 3 / 4, s.height * i / 3);
5242 s3->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT);
5243 s3->setContentSize(Size(s3->getContentSize().width, 200.0f));
5244 auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f));
5245 s3->runAction(action3);
5246
5247 if (i == 2)
5248 {
5249 s3->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f));
5250 s2->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f));
5251 s1->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f));
5252 }
5253
5254 // "anchor points"
5255 auto point = Sprite::create("Images/r1.png");
5256 point->setScale(0.25f);
5257 point->setPosition(s1->getPosition());
5258 addChild(point, 10);
5259
5260 auto point2 = Sprite::create("Images/r1.png");
5261 point2->setScale(0.25f);
5262 point2->setPosition(s2->getPosition());
5263 addChild(point2, 10);
5264
5265 auto point3 = Sprite::create("Images/r1.png");
5266 point3->setScale(0.25f);
5267 point3->setPosition(s3->getPosition());
5268 addChild(point3, 10);
5269 }

Callers

nothing calls this directly

Calls 13

getInstanceFunction · 0.85
createFunction · 0.85
SizeFunction · 0.50
RectClass · 0.50
setPositionMethod · 0.45
setAnchorPointMethod · 0.45
setContentSizeMethod · 0.45
getContentSizeMethod · 0.45
runActionMethod · 0.45
setScaleMethod · 0.45

Tested by

no test coverage detected