| 3783 | // AnimationCacheFile |
| 3784 | |
| 3785 | AnimationCacheFile::AnimationCacheFile() |
| 3786 | { |
| 3787 | auto frameCache = SpriteFrameCache::getInstance(); |
| 3788 | frameCache->addSpriteFramesWithFile("animations/grossini.plist"); |
| 3789 | frameCache->addSpriteFramesWithFile("animations/grossini_gray.plist"); |
| 3790 | frameCache->addSpriteFramesWithFile("animations/grossini_blue.plist"); |
| 3791 | |
| 3792 | // Purge previously loaded animation |
| 3793 | AnimationCache::destroyInstance(); |
| 3794 | |
| 3795 | auto animCache = AnimationCache::getInstance(); |
| 3796 | |
| 3797 | // Add an animation to the Cache |
| 3798 | animCache->addAnimationsWithFile("animations/animations.plist"); |
| 3799 | |
| 3800 | auto normal = animCache->getAnimation("dance_1"); |
| 3801 | normal->setRestoreOriginalFrame(true); |
| 3802 | auto dance_grey = animCache->getAnimation("dance_2"); |
| 3803 | dance_grey->setRestoreOriginalFrame(true); |
| 3804 | auto dance_blue = animCache->getAnimation("dance_3"); |
| 3805 | dance_blue->setRestoreOriginalFrame(true); |
| 3806 | |
| 3807 | auto animN = Animate::create(normal); |
| 3808 | auto animG = Animate::create(dance_grey); |
| 3809 | auto animB = Animate::create(dance_blue); |
| 3810 | |
| 3811 | auto seq = Sequence::create(animN, animG, animB, nullptr); |
| 3812 | |
| 3813 | // create an sprite without texture |
| 3814 | auto grossini = Sprite::create(); |
| 3815 | |
| 3816 | auto frame = frameCache->getSpriteFrameByName("grossini_dance_01.png"); |
| 3817 | grossini->setSpriteFrame(frame); |
| 3818 | |
| 3819 | auto winSize = Director::getInstance()->getWinSize(); |
| 3820 | |
| 3821 | grossini->setPosition(Vec2(winSize.width / 2, winSize.height / 2)); |
| 3822 | |
| 3823 | addChild(grossini); |
| 3824 | |
| 3825 | // run the animation |
| 3826 | grossini->runAction(seq); |
| 3827 | } |
| 3828 | |
| 3829 | AnimationCacheFile::~AnimationCacheFile() |
| 3830 | { |
nothing calls this directly
no test coverage detected