| 1422 | //------------------------------------------------------------------ |
| 1423 | |
| 1424 | Sprite6::Sprite6() |
| 1425 | { |
| 1426 | // small capacity. Testing resizing |
| 1427 | // Don't use capacity=1 in your real game. It is expensive to resize the capacity |
| 1428 | auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 1); |
| 1429 | addChild(batch, 0, kTagSpriteBatchNode); |
| 1430 | batch->setIgnoreAnchorPointForPosition(true); |
| 1431 | |
| 1432 | auto s = Director::getInstance()->getWinSize(); |
| 1433 | |
| 1434 | batch->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 1435 | batch->setContentSize(Size(s.width, s.height)); |
| 1436 | |
| 1437 | // SpriteBatchNode actions |
| 1438 | auto rotate = RotateBy::create(5, 360); |
| 1439 | auto action = RepeatForever::create(rotate); |
| 1440 | |
| 1441 | // SpriteBatchNode actions |
| 1442 | auto rotate_back = rotate->reverse(); |
| 1443 | auto rotate_seq = Sequence::create(rotate, rotate_back, nullptr); |
| 1444 | auto rotate_forever = RepeatForever::create(rotate_seq); |
| 1445 | |
| 1446 | auto scale = ScaleBy::create(5, 1.5f); |
| 1447 | auto scale_back = scale->reverse(); |
| 1448 | auto scale_seq = Sequence::create(scale, scale_back, nullptr); |
| 1449 | auto scale_forever = RepeatForever::create(scale_seq); |
| 1450 | |
| 1451 | float step = s.width / 4; |
| 1452 | |
| 1453 | for (int i = 0; i < 3; i++) |
| 1454 | { |
| 1455 | auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85 * i, 121 * 1, 85, 121)); |
| 1456 | sprite->setPosition(Vec2((i + 1) * step, s.height / 2)); |
| 1457 | |
| 1458 | sprite->runAction(action->clone()); |
| 1459 | batch->addChild(sprite, i); |
| 1460 | } |
| 1461 | |
| 1462 | batch->runAction(scale_forever); |
| 1463 | batch->runAction(rotate_forever); |
| 1464 | } |
| 1465 | |
| 1466 | std::string Sprite6::title() const |
| 1467 | { |
nothing calls this directly
no test coverage detected