当前位置: 首页>>代码示例>>C++>>正文


C++ CCAnimation::addFrame方法代码示例

本文整理汇总了C++中CCAnimation::addFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CCAnimation::addFrame方法的具体用法?C++ CCAnimation::addFrame怎么用?C++ CCAnimation::addFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCAnimation的用法示例。


在下文中一共展示了CCAnimation::addFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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));
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:26,代码来源:Card.cpp

示例2: JSValueMakeUndefined

JS_STATIC_FUNC_IMP(S_CCAnimation, jsAddFrame)
{
	//		void addFrame(CCSpriteFrame *pFrame);

	if (argumentCount == 1) {
		CCAnimation* self = (CCAnimation *)JSObjectGetPrivate(thisObject);
		JSStringRef str = JSValueToStringCopy(ctx, arguments[0], NULL);
		int len = JSStringGetLength(str);
		char *buff = (char *)malloc(len+1);
		JSStringGetUTF8CString(str, buff, len+1);
		
		CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(buff);
		if (frame) {
			self->addFrame(frame);
		}

		JSStringRelease(str);
		free(buff);
	}
	return JSValueMakeUndefined(ctx);
}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:21,代码来源:S_CCAnimation.cpp

示例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);
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:39,代码来源:CommDlg.cpp

示例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;
}
开发者ID:Double2,项目名称:IAPDevelop,代码行数:101,代码来源:HelloWorldScene.cpp


注:本文中的CCAnimation::addFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。