本文整理汇总了C++中CCNode::getActionByTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getActionByTag方法的具体用法?C++ CCNode::getActionByTag怎么用?C++ CCNode::getActionByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::getActionByTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activate
// When activated, scale the parent CCNode by the value of the activatedScale property.
// The current scale value of the parent is cached again, in case that scale had been
// changed since this adornment was added to the parent. We do not simply use a deactivation
// scale of 1 / activationScale in case the activation scaling is interrupted by the
// deactivation, and has not fully scaled up at the time the deactivation starts.
// The action is tagged so that it can be easily found if it needs to be cancelled.
void CCNodeAdornmentScaler::activate()
{
CCNode* p = getParent();
if ( p == NULL )
return;
CCAction* currAction = p->getActionByTag( kScaleActionTag );
if ( currAction )
{
// if we already have an active action, cancel it
p->stopAction( currAction );
}
else
{
// only cache scale if a scaling action is not active
// because otherwise scale will be evolvin and we'll cache something halfway
setOriginalScaleFromParent();
}
// use scaleTo instead of scaleBy so that final size is deterministic in the case
// where we have interrupted an active scaling action above
float finalScaleX = _originalScale.width * _activatedScale.width;
float finalScaleY = _originalScale.height * _activatedScale.height;
CCAction* scaleAction = CCActionScaleTo::create( getActionDuration(), finalScaleX, finalScaleY );
scaleAction->setTag( kScaleActionTag );
p->runAction( scaleAction );
}
示例2: showMoveAction
void CSmeltArmor::showMoveAction( const char* name )
{
CCNode* pNode = ((CCNode*)m_ui->findWidgetById(name));
if(pNode->getActionByTag(999) == nullptr)
{
CCRepeatForever* pAction = CCRepeatForever::create(CCSequence::createWithTwoActions(CCMoveBy::create(0.7f, ccp(0, 15)), CCMoveBy::create(0.7f, ccp(0, -15))));
pAction->setTag(999);
pNode->runAction(pAction);
}
}
示例3: ccTouchBegan
bool MainLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{ /*-- 跳动作 --*/
//CCDirector::sharedDirector()->replaceScene(FinishLayer::scene());
CCSize vsize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint location = pTouch->getLocation();
CCNode *node = 0;
if (location.x < vsize.width / 2)
{
if (!leftJumping)
{
node = this->getChildByTag(TAG_LEFT);
leftJumping = true;
}
}
else
{
if (!rightJumping)
{
node = this->getChildByTag(TAG_RIGHT);
rightJumping = true;
}
}
if (node)
{
CCActionInterval *jump = CCJumpBy::create(speed / ratio, ccp(0, 0),
node->getContentSize().height, 1);
node->runAction(jump);
CCActionInterval *moving = (CCActionInterval*) node->getActionByTag(
TAG_ACTION_MOVE);
if (moving)
{
node->runAction(CCSpeed::create(moving, 1.2f));
}
playJumpAnimation(node);
}
return true;
}