I am trying to play a frame animation sequence looping forever, but after each play, I'd like to delay for a period of time before the next loop.
Here's the specific code:
CCActionInterval *pAnimate = CCAnimate::create( m_pAnimationDebugSkill );
CCDelayTime *pDelayTime = CCDelayTime::create( 3.0f );
CCRepeatForever *pRepeat = CCRepeatForever::create( CCSequence::createWithTwoActions(pAnimate, pDelayTime) );
m_pSpriteDebugSkillAnimation->runAction( pRepeat );
I am expecting pAnimate to play, then pDelayTime to hold for 3 seconds, then pAnimate to play again... But what happens is pAnimate is playing and repeating forever... pDelayTime has no effect at all...
Anyone has any idea?
Here's the complete code:
// Skill button animation
m_pSpriteDebugSkillAnimation = CCSprite::createWithSpriteFrame(
CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(s_szNameSpriteFrame[UI_BOARD_RUNES_ANIM_BTN_SKILL_0])
);
m_pSpriteDebugSkillAnimation->setAnchorPoint(ccp(0.5f, 0.5f));
INT iNumFrames = UI_BOARD_RUNES_ANIM_BTN_SKILL_END - UI_BOARD_RUNES_ANIM_BTN_SKILL_START + 1;
CCArray *pAnimSkill = CCArray::create();
for ( INT i = 0; i < iNumFrames; i++ ) {
CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(s_szNameSpriteFrame[UI_BOARD_RUNES_ANIM_BTN_SKILL_0+i]);
pAnimSkill->addObject(pFrame);
}
m_pAnimationDebugSkill = CCAnimation::createWithSpriteFrames( pAnimSkill, DEFAULT_TIME_ANIM );
m_pAnimationDebugSkill->setLoops( -1 );
m_pAnimationDebugSkill->retain();
CCActionInterval *pAnimate = CCAnimate::create( m_pAnimationDebugSkill );
CCDelayTime *pDelayTime = CCDelayTime::create( 3.0f );
CCRepeatForever *pRepeat = CCRepeatForever::create( CCSequence::createWithTwoActions(pAnimate, pDelayTime) );
m_pSpriteDebugSkillAnimation->runAction( pRepeat );
CCSprite *pSpriteSkill = CCSprite::createWithSpriteFrame(
CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(s_szNameSpriteFrame[UI_BOARD_RUNES_BTN_SKILL])
);
FLOAT fSpriteSkillWidth = pSpriteSkill->boundingBox().size.width;
FLOAT fSpriteSkillHeight = pSpriteSkill->boundingBox().size.height;
m_pSpriteDebugSkillAnimation->setPosition(ccp(fSpriteSkillWidth/2.0f, fSpriteSkillHeight/2.0f));
pSpriteSkill->addChild( m_pSpriteDebugSkillAnimation );
//pSpriteSkill->setAnchorPoint(ccp(0.5f, 0.5f));
//pSpriteSkill->setPosition(ccp(fScreenHalfWidth, 1100.0f));
//this->addChild(pSpriteSkill);
m_pBtnDebugSkill = CCMenuItemSprite::create( pSpriteSkill, pSpriteSkill, pSpriteSkill, this, menu_selector(CGameScreen::onTouchSkillButton) );
m_pBtnDebugSkill->setPosition(ccp(fScreenHalfWidth, 1100.0f));
m_pMenuRoot->addChild( m_pBtnDebugSkill );