MCPcopy Create free account
hub / github.com/axmolengine/axmol / AnimationCacheFile

Method AnimationCacheFile

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:3785–3827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3783// AnimationCacheFile
3784
3785AnimationCacheFile::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
3829AnimationCacheFile::~AnimationCacheFile()
3830{

Callers

nothing calls this directly

Calls 10

getInstanceFunction · 0.85
createFunction · 0.85
addAnimationsWithFileMethod · 0.80
getSpriteFrameByNameMethod · 0.80
Vec2Function · 0.50
getAnimationMethod · 0.45
setSpriteFrameMethod · 0.45
setPositionMethod · 0.45
runActionMethod · 0.45

Tested by

no test coverage detected