------------------------------------------------------------------ Slice9 Test #8 ------------------------------------------------------------------
| 5662 | // |
| 5663 | //------------------------------------------------------------------ |
| 5664 | SpriteSlice9Test8::SpriteSlice9Test8() |
| 5665 | { |
| 5666 | Size s = Director::getInstance()->getVisibleSize(); |
| 5667 | |
| 5668 | SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini_family.plist"); |
| 5669 | SpriteFrameCache::getInstance()->addSpriteFramesWithFile("animations/grossini.plist"); |
| 5670 | |
| 5671 | // |
| 5672 | // flip BEFORE contentSize |
| 5673 | // |
| 5674 | auto s1 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); |
| 5675 | addChild(s1); |
| 5676 | s1->setPosition(s.width / 2 - s.width / 3, s.height * 2 / 3); |
| 5677 | s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5678 | s1->setCenterRectNormalized(Rect(1 / 3.f, 1 / 3.f, 1 / 3.f, 1 / 3.f)); |
| 5679 | s1->setFlippedX(true); |
| 5680 | s1->setContentSize(s1->getContentSize() * 2); |
| 5681 | |
| 5682 | auto s2 = Sprite::createWithSpriteFrameName("grossini.png"); |
| 5683 | addChild(s2); |
| 5684 | s2->setPosition(s.width * 2 / 4, s.height * 2 / 3); |
| 5685 | s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5686 | s2->setCenterRectNormalized(Rect(1 / 3.f, 1 / 3.f, 1 / 3.f, 1 / 3.f)); |
| 5687 | s2->setFlippedX(true); |
| 5688 | s2->setFlippedY(true); |
| 5689 | s2->setContentSize(s2->getContentSize() * 2); |
| 5690 | |
| 5691 | // Create reference sprite that's rotating based on there anchor point |
| 5692 | auto s3 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); |
| 5693 | addChild(s3); |
| 5694 | s3->setPosition(s.width / 2 + s.width / 3, s.height * 2 / 3); |
| 5695 | s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5696 | s3->setCenterRectNormalized(Rect(1 / 3.f, 1 / 3.f, 1 / 3.f, 1 / 3.f)); |
| 5697 | s3->setFlippedY(true); |
| 5698 | s3->setContentSize(s3->getContentSize() * 2); |
| 5699 | |
| 5700 | // |
| 5701 | // flip AFTER contentSize |
| 5702 | // |
| 5703 | auto s4 = Sprite::createWithSpriteFrameName("grossinis_sister1.png"); |
| 5704 | addChild(s4); |
| 5705 | s4->setPosition(s.width / 2 - s.width / 3, s.height * 1 / 3); |
| 5706 | s4->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5707 | s4->setCenterRectNormalized(Rect(1 / 3.f, 1 / 3.f, 1 / 3.f, 1 / 3.f)); |
| 5708 | s4->setFlippedX(true); |
| 5709 | s4->setContentSize(s4->getContentSize() * 2); |
| 5710 | |
| 5711 | auto s5 = Sprite::createWithSpriteFrameName("grossini.png"); |
| 5712 | addChild(s5); |
| 5713 | s5->setPosition(s.width * 2 / 4, s.height * 1 / 3); |
| 5714 | s5->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5715 | s5->setCenterRectNormalized(Rect(1 / 3.f, 1 / 3.f, 1 / 3.f, 1 / 3.f)); |
| 5716 | s5->setFlippedX(true); |
| 5717 | s5->setFlippedY(true); |
| 5718 | s5->setContentSize(s5->getContentSize() * 2); |
| 5719 | |
| 5720 | // Create reference sprite that's rotating based on there anchor point |
| 5721 | auto s6 = Sprite::createWithSpriteFrameName("grossinis_sister2.png"); |
nothing calls this directly
no test coverage detected