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

Method AnimationCacheTest

tests/cpp-tests/Source/SpriteTest/SpriteTest.cpp:3679–3763  ·  view source on GitHub ↗

------------------------------------------------------------------ AnimationCache ------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3677//
3678//------------------------------------------------------------------
3679AnimationCacheTest::AnimationCacheTest()
3680{
3681 auto frameCache = SpriteFrameCache::getInstance();
3682 frameCache->addSpriteFramesWithFile("animations/grossini.plist");
3683 frameCache->addSpriteFramesWithFile("animations/grossini_gray.plist");
3684 frameCache->addSpriteFramesWithFile("animations/grossini_blue.plist");
3685
3686 //
3687 // create animation "dance"
3688 //
3689 Vector<SpriteFrame*> animFrames(15);
3690 char str[100] = {0};
3691 for (int i = 1; i < 15; i++)
3692 {
3693 fmt::format_to_z(str, "grossini_dance_{:02d}.png", i);
3694 auto frame = frameCache->getSpriteFrameByName(str);
3695 animFrames.pushBack(frame);
3696 }
3697
3698 auto animation = Animation::createWithSpriteFrames(animFrames, 0.2f);
3699
3700 // Add an animation to the Cache
3701 AnimationCache::getInstance()->addAnimation(animation, "dance");
3702
3703 //
3704 // create animation "dance gray"
3705 //
3706 animFrames.clear();
3707
3708 for (int i = 1; i < 15; i++)
3709 {
3710 fmt::format_to_z(str, "grossini_dance_gray_{:02d}.png", i);
3711 auto frame = frameCache->getSpriteFrameByName(str);
3712 animFrames.pushBack(frame);
3713 }
3714
3715 animation = Animation::createWithSpriteFrames(animFrames, 0.2f);
3716
3717 // Add an animation to the Cache
3718 AnimationCache::getInstance()->addAnimation(animation, "dance_gray");
3719
3720 //
3721 // create animation "dance blue"
3722 //
3723 animFrames.clear();
3724
3725 for (int i = 1; i < 4; i++)
3726 {
3727 fmt::format_to_z(str, "grossini_blue_{:02d}.png", i);
3728 auto frame = frameCache->getSpriteFrameByName(str);
3729 animFrames.pushBack(frame);
3730 }
3731
3732 animation = Animation::createWithSpriteFrames(animFrames, 0.2f);
3733
3734 // Add an animation to the Cache
3735 AnimationCache::getInstance()->addAnimation(animation, "dance_blue");
3736

Callers

nothing calls this directly

Calls 13

getInstanceFunction · 0.85
format_to_zFunction · 0.85
createFunction · 0.85
getSpriteFrameByNameMethod · 0.80
pushBackMethod · 0.80
Vec2Function · 0.50
addAnimationMethod · 0.45
clearMethod · 0.45
getAnimationMethod · 0.45
setSpriteFrameMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected