本文整理汇总了C++中CCAnimation::setDelay方法的典型用法代码示例。如果您正苦于以下问题:C++ CCAnimation::setDelay方法的具体用法?C++ CCAnimation::setDelay怎么用?C++ CCAnimation::setDelay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCAnimation
的用法示例。
在下文中一共展示了CCAnimation::setDelay方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool IntroLayer::init()
{
bool pRet = false;
if (CCLayer::init())
{
// Accept touch input
this->setIsTouchEnabled(true);
hasBeenSkipped = false;
// Create the intro image
CCSprite *introImage = CCSprite::spriteWithFile("Menus/Intro/intro1.png");
introImage->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
this->addChild(introImage);
// Create the intro animation, and load it from intro1 to intro7.png
CCAnimation *introAnimation = CCAnimation::animation();
introAnimation->setDelay(3.5f);
char frameName[100] = {0};
for (int frameNumber=1; frameNumber < 8; frameNumber++)
{
CCLOG("Adding image intro%d.png to the introAnimation.",frameNumber);
sprintf(frameName, "Menus/Intro/intro%d.png", frameNumber);
introAnimation->addFrameWithFileName(frameName);
}
// Create the actions to play the intro
CCFiniteTimeAction *animationAction = CCAnimate::actionWithAnimation(introAnimation, false);
CCFiniteTimeAction *startGameAction = CCCallFunc::actionWithTarget(this, callfunc_selector(IntroLayer::startGamePlay));
CCFiniteTimeAction *introSequence = CCSequence::actions(animationAction, startGameAction, NULL);
introImage->runAction(introSequence);
pRet = true;
}
return pRet;
}
示例2: showSkillAnimation
//******************************************************************************
// showSkillAnimtion
//******************************************************************************
void Card::showSkillAnimation() {
CCAnimation *skillAnim = CCAnimation::animation();
char skillAnimName[100] = {0};
for (int i = 2; i <= 13 ; i++) {
sprintf(skillAnimName, "skill00%02d.png", i);
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(skillAnimName);
skillAnim->addFrame(frame);
}
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("blank.png");
skillAnim->addFrame(frame);
skillAnim->setDelay(0.5f / 14);
CCAnimate* skillAction = CCAnimate::actionWithAnimation(skillAnim, true);
CCSprite *spSkillAnim = CCSprite::spriteWithSpriteFrameName("skill0001.png");
spSkillAnim->setPositionInPixels(CCPointMake(55 + 106 * m_idx, 615));
spSkillAnim->setScale(2.0f);
addChild(spSkillAnim, 1, kToBeDeleteTag);
spSkillAnim->runAction(CCSequence::actions(skillAction,
CCCallFunc::actionWithTarget(this, callfunc_selector(Card::delUnusedObj)),
NULL));
}
示例3: initConnecting
//******************************************************************************
// initConnecting
//******************************************************************************
void CommDlg::initConnecting()
{
CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png");
if(sp){
addChild(sp);
}
char buf[100];
CCSprite *temSp = CCSprite::spriteWithSpriteFrameName("loading0001.png");
temSp->setPosition(CCPointMake(-120 - 15, 30));
addChild(temSp);
CCAnimation *loadingAnim = CCAnimation::animation();
char loadingAnimName[100] = {0};
for (int i = 1; i <= 8 ; i++) {
sprintf(loadingAnimName, "loading00%02d.png", i);
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( loadingAnimName );
loadingAnim->addFrame(frame);
}
loadingAnim->setDelay(1.0f / 8);
CCAnimate* loadingAction = CCAnimate::actionWithAnimation(loadingAnim, true);
temSp->runAction(CCRepeatForever::actionWithAction(loadingAction));
snprintf(buf, 99, "%s",OcProxy::Inst()->localizedStringStatic("loading_title"));
TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(200, 45), CCTextAlignmentCenter,45);
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
lbText->setPosition(CCPointMake(60 - 45, 20));
addChild(lbText, 2);
CCLabelTTF* ttfText = CCLabelTTF::labelWithString(OcProxy::Inst()->localizedStringStatic("loading_prompt"), CCSizeMake(360, 60), CCTextAlignmentCenter, "default.ttf", 20);
ttfText->setColor(ccc3(233, 183, 72));
ttfText->setPosition(CCPointMake(0, -80));
addChild(ttfText);
}
示例4: init
//.........这里部分代码省略.........
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(WorkSize_W - 20, 20) );
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu);
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 50);
pLabel->setPosition( ccp(WorkSize_W/ 2, WorkSize_H - 20) );
this->addChild(pLabel);
// 商店進入鈕
CCMenuItemImage *StoreItem = CCMenuItemImage::itemFromNormalImage(
"HelloWorld.png",
"HelloWorld.png",
this,
menu_selector(HelloWorld::StoreButtonCallback));
StoreItem->setPosition( ccp(WorkSize_W/2, WorkSize_H/2) );
StoreMenu = CCMenu::menuWithItems(StoreItem, NULL);
StoreMenu->setPosition( CCPointZero );
this->addChild(StoreMenu);
// 商店介面
spriteStoreBG = CCSprite::spriteWithSpriteFrameName("ui_shop_01.png");
spriteStoreBG->setPosition(fcp(Rectx, Recty));
spriteStoreBG->setIsVisible(false);
this->addChild(spriteStoreBG, Depth++);
// 商店離開鈕
CCMenuItem *StoreExitItem = CCMenuItemSprite::itemFromNormalSprite(
CCSprite::spriteWithSpriteFrameName("ui_shop_04.png"), CCSprite::spriteWithSpriteFrameName("ui_shop_04.png"), this, menu_selector(HelloWorld::StoreExitBtnCallback));
CCMenu *StoreExitMenu = CCMenu::menuWithItem(StoreExitItem);
StoreExitMenu->setPosition(ccp(StoreExitx, StoreExity));
spriteStoreBG->addChild(StoreExitMenu);
// 準備商店項目素材
frameStoreItems[0] = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("ui_shop_02.png"); // 金幣
frameStoreItems[1] = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("ui_shop_03.png"); // 籌碼
// 商店項目
for(int a = 0; a < MAX_IAP_NUM; a++)
{
// 商品項目
spriteStoreItems[a] = CCSprite::spriteWithSpriteFrame(frameStoreItems[0]);
spriteStoreItems[a]->setPosition(ccp(StoreItemx[a], StoreItemy[a]));
spriteStoreItems[a]->setOpacity(255);
spriteStoreItems[a]->setIsVisible(false);
spriteStoreBG->addChild(spriteStoreItems[a], a);
// 商品內容
labelItemContent[a] = CCLabelTTF::labelWithString("------", "arial", ItemContentFrontSize);
labelItemContent[a]->setColor(ccWHITE);
labelItemContent[a]->setPosition(ccp(ItemContentx[a],ItemContenty[a]));
spriteStoreItems[a]->addChild(labelItemContent[a]);
// 商項目購買金額初始化
labelItemPrice[a] = CCLabelTTF::labelWithString("------", "arial", ItemPriceFrontSize);
labelItemPrice[a]->setColor(ccWHITE);
labelItemPrice[a]->setPosition(ccp(ItemPricex[a],ItemPricey[a]));
spriteStoreItems[a]->addChild(labelItemPrice[a]);
}
// 商店Loading背景
spriteLoadingBG = CCSprite::spriteWithSpriteFrameName("loading10.png");
spriteLoadingBG->setPosition(fcp(LoadingBGx, LoadingBGy));
spriteLoadingBG->setIsVisible(false);
spriteLoadingBG->setScale(0.3f);
this->addChild(spriteLoadingBG, Depth++);
// 商店Loading背景動畫
spriteLoadingBG->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(1.0f, 360.0f)));
// 商店Loading文字(讀取中...)
spriteLoading = CCSprite::spriteWithSpriteFrameName("loading01.png");
spriteLoading->setPosition(fcp(Loadingx, Loadingy));
spriteLoading->setIsVisible(false);
this->addChild(spriteLoading, Depth++);
// 商店Loading文字字(讀取中...)動畫
CCAnimation* animation = CCAnimation::animation();
animation->setDelay(0.1f);
for(int a = 0; a < 8; a++)
{
a < 1 ?
sprintf(ResourceName, "loading%02d.png", 1):
sprintf(ResourceName, "loading%02d.png", a);
animation->addFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(ResourceName));
spriteLoading->runAction(CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(animation, true)));
}
return true;
}