本文整理汇总了C++中AnimationFrame::getSpriteFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationFrame::getSpriteFrame方法的具体用法?C++ AnimationFrame::getSpriteFrame怎么用?C++ AnimationFrame::getSpriteFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimationFrame
的用法示例。
在下文中一共展示了AnimationFrame::getSpriteFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void YHCCActionHelper::runIntervalForeverAnimation2(float interval, cocos2d::CCAnimation * animation,
cocos2d::CCSprite * pSprite,
const std::function<void ()> & begin_callback,
const std::function<void ()> & end_callback)
{
Vector<FiniteTimeAction *> actions;
Animate * animate = Animate::create(animation);
Hide * hide = Hide::create();
DelayTime * delay = DelayTime::create(interval);
Show * show = Show::create();
if (begin_callback != nullptr)
{
CallFunc * callfunc = CallFunc::create(begin_callback);
actions.pushBack(callfunc);
}
actions.pushBack(animate);
actions.pushBack(hide);
actions.pushBack(delay);
actions.pushBack(show);
if (end_callback != nullptr)
{
CallFunc * callfunc = CallFunc::create(end_callback);
actions.pushBack(callfunc);
}
Sequence * sequence = Sequence::create(actions);
RepeatForever * repeatForever = RepeatForever::create(sequence);
AnimationFrame * frame = animate->getAnimation()->getFrames().at(0);
pSprite->setDisplayFrame(frame->getSpriteFrame());
pSprite->runAction(repeatForever);
}
示例2: setDisplayFrameWithAnimationName
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex)
{
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr");
Animation *a = AnimationCache::getInstance()->getAnimation(animationName);
CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");
AnimationFrame* frame = a->getFrames().at(frameIndex);
CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame");
setSpriteFrame(frame->getSpriteFrame());
}