本文整理汇总了C++中ActionNode::getFirstSpriteFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionNode::getFirstSpriteFrame方法的具体用法?C++ ActionNode::getFirstSpriteFrame怎么用?C++ ActionNode::getFirstSpriteFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionNode
的用法示例。
在下文中一共展示了ActionNode::getFirstSpriteFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performAnimation
void Object::performAnimation(string name, SEL_CallFunc func){
if (this->getCurrentObjectState() == ObjectStateDead && name.compare("Dead") != 0) {
return;
}
CCSpriteBatchNode *currentSpriteBatchNode = m_pobBatchNode;
CCSpriteBatchNode *newSpriteBatchNode = NULL;
// Get the action pair by key name
CCArray *actionPair = (CCArray *)actionsHashes->objectForKey(name);
// If the action pair does not exist, return early
if (!actionPair) {
return;
}
newSpriteBatchNode = (CCSpriteBatchNode *)actionPair->objectAtIndex(1);
ActionNode *actionNode = (ActionNode *)actionPair->objectAtIndex(0);
this->stopActionByTag(ACTION_ANIMATION_TAG);
// If required spriteBatchNode is different from current, replace it
if (currentSpriteBatchNode != newSpriteBatchNode) {
this->removeFromParentAndCleanup(false);
this->setTexture(actionNode->getFirstSpriteFrame()->getTexture());
this->setTextureRect(actionNode->getFirstSpriteFrame()->getRect());
newSpriteBatchNode->addChild(this);
}
if (func != NULL) {
CCAssert(dynamic_cast<CCRepeatForever*>(actionNode->getAnimation()) == NULL, "Not able to call function for CCRepeatForever action.");
// Create animation followed by a function call
CCSequence *seq = CCSequence::createWithTwoActions(actionNode->getAnimation(), CCCallFunc::create(this, func));
seq->setTag(ACTION_ANIMATION_TAG);
this->runAction(seq);
} else {
// Run the action
actionNode->getAnimation()->setTag(ACTION_ANIMATION_TAG);
this->runAction(actionNode->getAnimation());
}
// Run AI in this action
{
if (actionPair->count() > 2) {
CCArray *AIActions = (CCArray *)actionPair->objectAtIndex(2);
CCLOG("%s is running AI, total AIAction count: %d", identifier.c_str(), AIActions->count());
for (int i = 0; i < AIActions->count(); i++) {
CCAction *action = (CCAction*)AIActions->objectAtIndex(i);
this->runAction(action);
}
}
}
}