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


C++ CCSpriteFrameCache::addSpriteFramesWithFile方法代码示例

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


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

示例1: ccp

KDbool Ch2_AnalogStick::init ( KDvoid )
{	
	if ( !Recipe::init ( ) )
	{
		return KD_FALSE;
	}

	CCSpriteFrameCache*		pCache = CCSpriteFrameCache::sharedSpriteFrameCache ( );
	pCache->addSpriteFramesWithFile ( "gunman.plist" );

	// Initialize gunman
	m_pGunman = SimpleAnimObject::createWithSpriteFrame ( pCache->spriteFrameByName ( "gunman_stand_down.png" ) );
	m_pGunman->setPosition ( ccp ( 240, 160 ) );
	m_pGunman->setVelocity ( ccp ( 0, 0 ) );
	this->addChild ( m_pGunman );
	m_nGunmanDirection = AS_DOWN;

	m_pMessage->setString ( "Analog Vector:" );
		
	// Initialize analog stick
	pCache->addSpriteFramesWithFile ( "analog_stick.plist" );
	m_pAnalogStick = AnalogStick::create ( );
	m_pAnalogStick->setPosition ( ccp ( 100, 100 ) );
	this->addChild ( m_pAnalogStick );

	// This sets off a chain reaction.
	this->animateGunman ( );

	this->schedule ( schedule_selector ( Ch2_AnalogStick::step ) );

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:32,代码来源:Ch2_AnalogStick.cpp

示例2: InitializeResource

void GameRoot::InitializeResource()
{
	CCSpriteFrameCache* cache = 
			CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("GameUI01.plist", "GameUI01.png");
	cache->addSpriteFramesWithFile("GameUI02.plist", "GameUI02.png");
	cache->addSpriteFramesWithFile("ActorsPack1.plist", "ActorsPack1.png");
}
开发者ID:jonesgithub,项目名称:dotawar,代码行数:8,代码来源:GameRoot.cpp

示例3: bindInitialImageTexture

//绑定初始资源,这是从APK里直接读取,这里的资源永远不要更新。
void ResourceManager::bindInitialImageTexture()
{
   
    CCSpriteFrameCache* sfc = CCSpriteFrameCache::sharedSpriteFrameCache();
    //公用资源。
    sfc->addSpriteFramesWithFile("public/public1.plist");
    sfc->addSpriteFramesWithFile("public/public2.plist");
    //LOADING小红帽。
    sfc->addSpriteFramesWithFile("animationFile/animation_loading.plist");

}
开发者ID:caoguoping,项目名称:warCraft,代码行数:12,代码来源:ResourceManager.cpp

示例4: init

bool StoryEnd::init()
{
	if (!Story::init())
	{
		return false;
	}	
	dialogBox_bottom->setVisible(false);	//设置对话框不可见
	dialogBox_top->setVisible(false);
	CCSpriteFrameCache* frameStart = CCSpriteFrameCache::sharedSpriteFrameCache();
	frameStart->addSpriteFramesWithFile("Story00.plist","Story00.png");
	frameStart->addSpriteFramesWithFile("StoryEnd.plist","StoryEnd.png");
	count = 1;
	nextEvt();												//由此进入第一个事件
	return true;
}
开发者ID:Jormungendr,项目名称:HotPunch,代码行数:15,代码来源:StoryEnd.cpp

示例5: updateInfo

void* LoadingLayer::updateInfo(void* args)
{

    // 开线程加载plist文件,将plist加载到CCSpriteFrameCache
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    CCTextureCache* teCache = CCTextureCache::sharedTextureCache();
    for (int i=0; i<m_staticYPlist->count() * 0.5; i++)
    {
        const char* m_pngFullPath = ((CCString* )m_staticYPlist->objectAtIndex(i))->getCString();
        const char* m_plistFullPath = ((CCString* )m_staticYPlist->objectAtIndex(i + m_staticYPlist->count() * 0.5))->getCString();
//        CCLog("m_pngFullPath:%s", m_pngFullPath);
//        CCLog("m_plistFullPath:%s", m_plistFullPath);
        
        CCTexture2D* texture = teCache->textureForKey(m_pngFullPath);
        cache->addSpriteFramesWithFile(m_plistFullPath, texture);
        // 删除纹理
        teCache->removeTextureForKey(m_pngFullPath);
    }
    // 可以异步加载数据 m_target为空,就跳过
    if (m_instance->m_target)
    {
        if (m_instance->m_callFuncData)
        {
            (m_instance->m_target->*m_instance->m_callFuncData)();
        }
        
    }
    m_instance->isOver = true;
//    m_taxiBus->runAction(CCSequence::create(
//                                            CCMoveTo::create(0.7, ccp(m_moveLength, m_taxiBus->getPosition().y)),
//                                            CCCallFunc::create(m_instance, callfunc_selector(LoadingLayer::loadingSuccessful)),
//                                            NULL));

    return NULL;
}
开发者ID:jtly1985,项目名称:MytestGitHub,代码行数:35,代码来源:LoadingLayer.cpp

示例6: slowDown

void Planet::slowDown()
{
	// 当前的逻辑禁止在一个减速期间叠加另一个减速
	if(m_bSlowDowned)
		return;

	m_bSlowDowned = true;	

	if(!m_pSlowDownMark)
	{
		setSlowDownMark(CCSprite::create());
		m_pSlowDownMark->setPosition(ccp(113,65));
		this->addChild(m_pSlowDownMark);
	}

	m_pSlowDownMark->setVisible(true);	

	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("SlowDownMark.plist");
	CCAnimation* animation = CCAnimation::create();
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_0.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_1.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_2.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_3.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));
	animation->setDelayPerUnit(0.2f);
	CCAnimate* animate = CCAnimate::create(animation);
	m_pSlowDownMark->runAction(CCRepeatForever::create(animate));	

	this->scheduleOnce(schedule_selector(Planet::slowDownRestore) , SLOW_DOWN_DURATION);

	if(m_pFace)
		m_pFace->cry();
}
开发者ID:daoduchai,项目名称:DogsMustDie,代码行数:35,代码来源:Planet.cpp

示例7: init

bool CCActivityIndicator::init()
{
    CCSpriteFrameCache * spriteFramecache = CCSpriteFrameCache::sharedSpriteFrameCache();
    
    spriteFramecache->addSpriteFramesWithFile("ccactivityindicator.plist");
    CCSpriteBatchNode::initWithFile("ccactivityindicator.png", 1);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    indicator = CCSprite::createWithSpriteFrameName("ccactivityindicator_1.gif");
    indicator->setPosition(ccp(winSize.width/2,winSize.height/2));
    addChild(indicator);
    
    animating = false;
    hidesWhenStopped = true;
    
    spriteFrames = CCArray::create();
    spriteFrames->retain();
    
    //load all sprite frames into array
    for (int i=1; i<=kActivityIndicatorFramesCount; i++) {
        CCSpriteFrame * frame = spriteFramecache->spriteFrameByName(CCString::createWithFormat("ccactivityindicator_%d.gif",i)->getCString());
        spriteFrames->addObject(frame);
    }
    
    return true;
}
开发者ID:JLimqueco,项目名称:cocos2d-x-extensions,代码行数:26,代码来源:CCActivityIndicator.cpp

示例8: initPlayer

void GameLayer::initPlayer()
{

	CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
		frameCache->addSpriteFramesWithFile("LuckyFlying.plist");

		CCSpriteBatchNode* pigeonFlightSheet = CCSpriteBatchNode::create("LuckyFlying.png");
		addChild(pigeonFlightSheet, 3);

		CCArray* pigeonFrames = new CCArray;
		for ( int i = 2; i <= 4; i++)
		{
			CCString* filename = CCString::createWithFormat("lucky_flying_0000%d.png", i);
			CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(filename->getCString());
			pigeonFrames->addObject(frame);
		}

		CCAnimation* flightAnim = CCAnimation::createWithSpriteFrames(pigeonFrames, 0.1);
		pigeonSprite = CCSprite::createWithSpriteFrameName("lucky_flying_00002.png");

		//pigeonSprite->setScale(0.5f);
		pigeonSprite->setPosition(ccp(SCREEN_WIDTH/2 - 500, SCREEN_WIDTH*3 + 250));

		CCAction* flightAction = CCRepeatForever::create(CCAnimate::create(flightAnim));
		pigeonSprite->runAction(flightAction);
		pigeonFlightSheet->addChild(pigeonSprite, 3);

		schedule(schedule_selector(GameLayer::tick1), 0.10f);
		schedule(schedule_selector(GameLayer::tick2), 0.03f);

}
开发者ID:aebert1,项目名称:LBird,代码行数:31,代码来源:GameLayers.cpp

示例9: loadUI

void BYGameScene::loadUI() {
    
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    frameCache->addSpriteFramesWithFile("ui.plist", "ui.png");
    
    CCSize winSize    = CCDirector::sharedDirector()->getWinSize();    
    
    /// pause button
    CCSprite* btnNormalSprite = CCSprite::createWithSpriteFrameName("pause.png");
    CCMenuItemSprite *pauseMenuItem = CCMenuItemSprite::create(btnNormalSprite,
                                                               btnNormalSprite,
                                                               this,
                                                               menu_selector(BYGameScene::pauseButtonHandler));
    
    /// 2 labels for goals
    ccColor3B color = ccc3(220, 70, 20); /// red color
    _labelBotPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelBotPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelBot = CCMenuItemLabel::create(_labelBotPlayerGoalsScored, NULL, NULL);
    labelBot->setEnabled(false);
    
    _labelTopPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelTopPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelTop = CCMenuItemLabel::create(_labelTopPlayerGoalsScored, NULL, NULL);
    labelTop->setEnabled(false);
    
    /// CCMenu doesnt support anchorPoint as of 0x00020003 version
    CCMenu *menu = CCMenu::create(labelTop, pauseMenuItem, labelBot, NULL);
    menu->alignItemsHorizontallyWithPadding(5);
    menu->setAnchorPoint(CCPointMake(0, 0));
    menu->setPosition(CCPointMake(winSize.width - pauseMenuItem->getContentSize().width / 2,
                                  winSize.height / 2));
    menu->setRotation(90);
    this->addChild(menu);
}
开发者ID:myeyesareblind,项目名称:touchHockey,代码行数:35,代码来源:BYGameScene.cpp

示例10: init

KDbool AnalogStick::init ( KDvoid )
{
	if ( !TouchableSprite::init ( ) )
	{
		return KD_FALSE;
	}

	this->setScale ( 0.5f );
		
	m_tPressedVector = ccp ( 0, 0 );
	m_nDirection = AS_NO_DIRECTION;
		
	CCSpriteFrameCache*		pCache = CCSpriteFrameCache::sharedSpriteFrameCache ( );
	pCache->addSpriteFramesWithFile ( "analog_stick.plist" );
		
	// Set the sprite display frame
	this->setDisplayFrame ( pCache->spriteFrameByName ( "analog_pad.png" ) );
		
	// Init the bar, set position and display frame
	m_pBar = CCSprite::create ( );
	m_pBar->setDisplayFrame ( pCache->spriteFrameByName ( "analog_bar.png" ) );
	this->repositionBarWithPoint ( this->getPosition ( ) );
	this->addChild ( m_pBar );
	
	// Init the nub, set position and display frame
	m_pNub = CCSprite::create ( );
	this->repositionNub ( );
	m_pNub->setDisplayFrame ( pCache->spriteFrameByName ( "analog_nub.png" ) );
	this->addChild ( m_pNub );	

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:32,代码来源:AnalogStick.cpp

示例11: displayHurt

void Mole::displayHurt()
{
		this->unscheduleAllSelectors();
		if(!isAction)
		{
			CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mole_11.png");
			m_mole->setDisplayFrame(frame);
			CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
			frameCache->addSpriteFramesWithFile("wakuang/mole_hurt.plist");
			CCSpriteFrame* frame1 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20543.png");
			CCSpriteFrame* frame2 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20544.png");
			CCSpriteFrame* frame3 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20545.png");
			CCArray* animFrames = CCArray::createWithCapacity(3);
			animFrames->addObject(frame1);
			animFrames->addObject(frame2);
			animFrames->addObject(frame3);
			CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.15f);
			animation->setRestoreOriginalFrame(true);
			animFrames->removeAllObjects();
			m_spade->runAction(CCAnimate::create(animation));		
			CCSpriteFrame* frame4 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20546.png");
			CCSpriteFrame* frame5 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20547.png");
			CCSpriteFrame* frame6 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("20548.png");
			animFrames->addObject(frame4);
			animFrames->addObject(frame5);
			animFrames->addObject(frame6);
			animation = CCAnimation::createWithSpriteFrames(animFrames, 0.15f);
			animation->setRestoreOriginalFrame(true);
			animFrames->removeAllObjects();
			CCCallFunc* call = CCCallFunc::create(this,callfunc_selector(Mole::hurtActionOver));
			m_hurt->runAction(CCSequence::create(CCAnimate::create(animation),call,NULL));
			isAction = true;
			sendEvent(type);
		}
}
开发者ID:captainwanghq,项目名称:demos,代码行数:35,代码来源:Mole.cpp

示例12: init

bool Mole::init()
{
		CCNode::init();
		CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
		frameCache->addSpriteFramesWithFile("wakuang/mole.plist");
		CCArray* animFrames = CCArray::createWithCapacity(3);
		char str[128] = {0};	
		CCSpriteFrame *frame1 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mole_01.png");
		CCSpriteFrame *frame2 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mole_02.png");
		CCSpriteFrame *frame3 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(this->getSpriteFramesName().c_str());
		animFrames->addObject(frame1);
		animFrames->addObject(frame2);
		animFrames->addObject(frame3);
		CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.15f);
		animation->setRestoreOriginalFrame(true);
		animFrames->removeAllObjects();
		m_mole = CCSprite::create();
		m_mole->setDisplayFrame(frame3);
		CCCallFunc* call = CCCallFunc::create(this,callfunc_selector(Mole::displayActionOver));
		m_mole->runAction(CCSequence::create(CCAnimate::create(animation),call,NULL));
		this->addChild(m_mole);
		m_spade = CCSprite::create();
		this->addChild(m_spade);
		m_hurt=CCSprite::create();
		this->addChild(m_hurt);
	return true;
}
开发者ID:captainwanghq,项目名称:demos,代码行数:27,代码来源:Mole.cpp

示例13: addPig

void GameScene::addPig()
{
    const static int fameCount = 3;
    const static float animationDuration = 0.15f;

    CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("pigs.plist");

    m_pPig = CCSprite::createWithSpriteFrameName("pig1");
    m_pPig->retain();
    m_pPig->setScale(0.7f);
    m_pPig->setZOrder(1);
    m_pPig->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 3, m_VisibleOrigin.y + m_VisibleSize.height / 2));
    addChild(m_pPig);

    CCArray *animFrames = CCArray::createWithCapacity(fameCount);
    for(int i = 1; i <= fameCount; i++)
    {
        CCSpriteFrame* frame = cache->spriteFrameByName(CCString::createWithFormat("pig%d", i)->getCString());
        animFrames->addObject(frame);
    }

    CCAction *action = CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(animFrames, animationDuration)));
    action->setTag(kTagFlutter);
    m_pPig->runAction(action);
}
开发者ID:studio501,项目名称:fiypig,代码行数:26,代码来源:GameScene.cpp

示例14: init

bool BulletPool::init()
{
	bool bRet = false;
    
    do {
		bullets = CCArray::createWithCapacity(MAX_SIZE);
		bullets->retain();
		CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
		cache->addSpriteFramesWithFile("bullet.plist");

		bspritesheet =  CCSpriteBatchNode::create("bullet.png");

		for (int i = 0; i < MAX_SIZE; i ++)
		{
			Bullet *bullet = Bullet::create("W1.png", bspritesheet, NULL);
			bullet->setVisible(false);
			bullet->setRotation(90.0f);
			bullets->addObject(bullet);
		}

		next = 0;

		bRet = true;
	} while (0);
	
	return bRet;

}
开发者ID:Ken93,项目名称:Simple2dShooter,代码行数:28,代码来源:BulletPool.cpp

示例15: init

bool FWEffectSprite::init(const char *effectName,
                       int frameCount,
                       float delay,
                       bool deleteAfterFinishing)
{
    CCString *psPlistFile = CCString::createWithFormat("%s.plist", effectName);

    CCSpriteFrameCache *psfcFrameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    psfcFrameCache->addSpriteFramesWithFile(psPlistFile->getCString());
    
    CCString *psFrameName = CCString::createWithFormat("%s_0.png", effectName);
    const char * pccFrameName = psFrameName->getCString();
//    m_psfSpriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pccFrameName);
    
    if (!CCSprite::initWithSpriteFrameName(pccFrameName))
    {
        return false;
    }
    
    CCAnimation *paAnimation = FWAnimation::create(effectName, frameCount, delay);
    CCAnimate *paAnimate = CCAnimate::create(paAnimation);
    
    if (deleteAfterFinishing)
    {
        CCCallFunc *pcfCallBack = CCCallFunc::create(this, callfunc_selector(FWEffectSprite::removeSelf));
        CCSequence *pseSeq = CCSequence::createWithTwoActions(paAnimate, pcfCallBack);
        runAction(pseSeq);
    }
    else
    {
        runAction(paAnimate);
    }
    return true;
}
开发者ID:b00yan,项目名称:Framework_cocos2dx,代码行数:34,代码来源:FWEffectSprite.cpp


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