| 2478 | } |
| 2479 | |
| 2480 | bool Animate::initWithAnimation(Animation* animation) |
| 2481 | { |
| 2482 | AXASSERT(animation != nullptr, "Animate: argument Animation must be non-nullptr"); |
| 2483 | if (animation == nullptr) |
| 2484 | { |
| 2485 | AXLOGE("Animate::initWithAnimation: argument Animation must be non-nullptr"); |
| 2486 | return false; |
| 2487 | } |
| 2488 | |
| 2489 | float singleDuration = animation->getDuration(); |
| 2490 | |
| 2491 | if (ActionInterval::initWithDuration(singleDuration * animation->getLoops())) |
| 2492 | { |
| 2493 | _nextFrame = 0; |
| 2494 | setAnimation(animation); |
| 2495 | _origFrame = nullptr; |
| 2496 | _executedLoops = 0; |
| 2497 | |
| 2498 | _splitTimes->reserve(animation->getFrames().size()); |
| 2499 | |
| 2500 | float accumUnitsOfTime = 0; |
| 2501 | float newUnitOfTimeValue = singleDuration / animation->getTotalDelayUnits(); |
| 2502 | |
| 2503 | auto& frames = animation->getFrames(); |
| 2504 | |
| 2505 | for (auto&& frame : frames) |
| 2506 | { |
| 2507 | float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration; |
| 2508 | accumUnitsOfTime += frame->getDelayUnits(); |
| 2509 | _splitTimes->emplace_back(value); |
| 2510 | } |
| 2511 | return true; |
| 2512 | } |
| 2513 | return false; |
| 2514 | } |
| 2515 | |
| 2516 | void Animate::setAnimation(ax::Animation* animation) |
| 2517 | { |
no test coverage detected