------------------------------------------------------------------ Slice9 Test #2 ------------------------------------------------------------------
| 5275 | // |
| 5276 | //------------------------------------------------------------------ |
| 5277 | SpriteSlice9Test2::SpriteSlice9Test2() |
| 5278 | { |
| 5279 | SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini_family.plist"); |
| 5280 | SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini.plist"); |
| 5281 | |
| 5282 | Size s = Director::getInstance()->getWinSize(); |
| 5283 | |
| 5284 | for (int i = 2; i > 0; i--) |
| 5285 | { |
| 5286 | // Create reference sprite that's rotating based on there anchor point |
| 5287 | auto s1 = Sprite::createWithSpriteFrameName("grossini.png"); |
| 5288 | addChild(s1); |
| 5289 | s1->setPosition(s.width * 1 / 4, s.height * i / 3); |
| 5290 | s1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); |
| 5291 | s1->setContentSize(Size(80.0f, s1->getContentSize().height)); |
| 5292 | auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5293 | s1->runAction(action1); |
| 5294 | |
| 5295 | // Create reference sprite that's rotating based on there anchor point |
| 5296 | auto s2 = Sprite::createWithSpriteFrameName("grossini.png"); |
| 5297 | addChild(s2); |
| 5298 | s2->setPosition(s.width * 2 / 4, s.height * i / 3); |
| 5299 | s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5300 | s2->setContentSize(Size(80.0f, s2->getContentSize().height)); |
| 5301 | auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5302 | s2->runAction(action2); |
| 5303 | |
| 5304 | // Create reference sprite that's rotating based on there anchor point |
| 5305 | auto s3 = Sprite::createWithSpriteFrameName("grossini.png"); |
| 5306 | addChild(s3); |
| 5307 | s3->setPosition(s.width * 3 / 4, s.height * i / 3); |
| 5308 | s3->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); |
| 5309 | s3->setContentSize(Size(80.0f, s3->getContentSize().height)); |
| 5310 | auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5311 | s3->runAction(action3); |
| 5312 | |
| 5313 | if (i == 2) |
| 5314 | { |
| 5315 | s3->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); |
| 5316 | s2->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); |
| 5317 | s1->setCenterRectNormalized(Rect(0.4f, 0.4f, 0.2f, 0.2f)); |
| 5318 | } |
| 5319 | |
| 5320 | // "anchor points" |
| 5321 | auto point = Sprite::create("Images/r1.png"); |
| 5322 | point->setScale(0.25f); |
| 5323 | point->setPosition(s1->getPosition()); |
| 5324 | addChild(point, 10); |
| 5325 | |
| 5326 | auto point2 = Sprite::create("Images/r1.png"); |
| 5327 | point2->setScale(0.25f); |
| 5328 | point2->setPosition(s2->getPosition()); |
| 5329 | addChild(point2, 10); |
| 5330 | |
| 5331 | auto point3 = Sprite::create("Images/r1.png"); |
| 5332 | point3->setScale(0.25f); |
| 5333 | point3->setPosition(s3->getPosition()); |
| 5334 | addChild(point3, 10); |
nothing calls this directly
no test coverage detected