| 2337 | //------------------------------------------------------------------ |
| 2338 | |
| 2339 | SpriteOffsetAnchorScale::SpriteOffsetAnchorScale() |
| 2340 | { |
| 2341 | auto s = Director::getInstance()->getWinSize(); |
| 2342 | |
| 2343 | auto cache = SpriteFrameCache::getInstance(); |
| 2344 | cache->addSpriteFramesWithFile("animations/grossini.plist"); |
| 2345 | cache->addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png"); |
| 2346 | |
| 2347 | for (int i = 0; i < 3; i++) |
| 2348 | { |
| 2349 | // |
| 2350 | // Animation using Sprite BatchNode |
| 2351 | // |
| 2352 | auto sprite = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); |
| 2353 | sprite->setPosition(Vec2(s.width / 4 * (i + 1), s.height / 2)); |
| 2354 | |
| 2355 | auto point = Sprite::create("Images/r1.png"); |
| 2356 | point->setScale(0.25f); |
| 2357 | point->setPosition(sprite->getPosition()); |
| 2358 | addChild(point, 1); |
| 2359 | |
| 2360 | switch (i) |
| 2361 | { |
| 2362 | case 0: |
| 2363 | sprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); |
| 2364 | break; |
| 2365 | case 1: |
| 2366 | sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); |
| 2367 | break; |
| 2368 | case 2: |
| 2369 | sprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); |
| 2370 | break; |
| 2371 | } |
| 2372 | |
| 2373 | point->setPosition(sprite->getPosition()); |
| 2374 | |
| 2375 | Vector<SpriteFrame*> animFrames(14); |
| 2376 | char str[100] = {0}; |
| 2377 | for (int i = 0; i < 14; i++) |
| 2378 | { |
| 2379 | fmt::format_to_z(str, "grossini_dance_{:02d}.png", (i + 1)); |
| 2380 | auto frame = cache->getSpriteFrameByName(str); |
| 2381 | animFrames.pushBack(frame); |
| 2382 | } |
| 2383 | |
| 2384 | auto animation = Animation::createWithSpriteFrames(animFrames, 0.3f); |
| 2385 | sprite->runAction(RepeatForever::create(Animate::create(animation))); |
| 2386 | |
| 2387 | auto scale = ScaleBy::create(2, 2); |
| 2388 | auto scale_back = scale->reverse(); |
| 2389 | auto seq_scale = Sequence::create(scale, scale_back, nullptr); |
| 2390 | sprite->runAction(RepeatForever::create(seq_scale)); |
| 2391 | |
| 2392 | addChild(sprite, 0); |
| 2393 | } |
| 2394 | } |
| 2395 | |
| 2396 | void SpriteOffsetAnchorScale::onExit() |
nothing calls this directly
no test coverage detected