------------------------------------------------------------------ Slice9 Test #3 ------------------------------------------------------------------
| 5341 | // |
| 5342 | //------------------------------------------------------------------ |
| 5343 | SpriteSlice9Test3::SpriteSlice9Test3() |
| 5344 | { |
| 5345 | Size s = Director::getInstance()->getWinSize(); |
| 5346 | |
| 5347 | for (int i = 2; i > 0; --i) |
| 5348 | { |
| 5349 | // Create reference sprite that's rotating based on there anchor point |
| 5350 | auto s1 = Sprite::create("ccb/scale-9-demo.png"); |
| 5351 | addChild(s1); |
| 5352 | s1->setPosition(s.width * 1 / 4, s.height * i / 3); |
| 5353 | s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5354 | s1->setContentSize(s1->getContentSize()); |
| 5355 | auto action1 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5356 | s1->runAction(action1); |
| 5357 | |
| 5358 | // Create reference sprite that's rotating based on there anchor point |
| 5359 | auto s2 = Sprite::create("ccb/scale-9-demo.png"); |
| 5360 | addChild(s2); |
| 5361 | s2->setPosition(s.width * 2 / 4, s.height * i / 3); |
| 5362 | s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5363 | s2->setContentSize(s2->getContentSize() * 2); |
| 5364 | auto action2 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5365 | s2->runAction(action2); |
| 5366 | |
| 5367 | // Create reference sprite that's rotating based on there anchor point |
| 5368 | auto s3 = Sprite::create("ccb/scale-9-demo.png"); |
| 5369 | addChild(s3); |
| 5370 | s3->setPosition(s.width * 3 / 4, s.height * i / 3); |
| 5371 | s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 5372 | s3->setContentSize(s3->getContentSize() * 3); |
| 5373 | auto action3 = RepeatForever::create(RotateBy::create(5.0f, 360.0f)); |
| 5374 | s3->runAction(action3); |
| 5375 | |
| 5376 | // enable slice 9, only in the first row |
| 5377 | if (i == 2) |
| 5378 | { |
| 5379 | s1->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); |
| 5380 | s2->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); |
| 5381 | s3->setCenterRectNormalized(Rect(0.4, 0.4, 0.2, 0.2)); |
| 5382 | } |
| 5383 | |
| 5384 | // "anchor points" |
| 5385 | auto point = Sprite::create("Images/r1.png"); |
| 5386 | point->setScale(0.25f); |
| 5387 | point->setPosition(s1->getPosition()); |
| 5388 | addChild(point, 10); |
| 5389 | |
| 5390 | auto point2 = Sprite::create("Images/r1.png"); |
| 5391 | point2->setScale(0.25f); |
| 5392 | point2->setPosition(s2->getPosition()); |
| 5393 | addChild(point2, 10); |
| 5394 | |
| 5395 | auto point3 = Sprite::create("Images/r1.png"); |
| 5396 | point3->setScale(0.25f); |
| 5397 | point3->setPosition(s3->getPosition()); |
| 5398 | addChild(point3, 10); |
| 5399 | } |
| 5400 | } |
nothing calls this directly
no test coverage detected