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


C++ CCDictionary::removeAllObjects方法代码示例

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


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

示例1: addAndroidStrings

void CCLocalization::addAndroidStrings(const string& lan, const string& path, bool merge) {
    // basic checking
    if(path.empty()) {
        CCLOGWARN("CCLocalization::addAndroidStrings: string file path is empty");
        return;
    }
    if(lan.length() != 2) {
        CCLOGWARN("CCLocalization::addAndroidStrings: language code is not in ISO 639-1 format");
        return;
    }

    // register language dictionary
    CCDictionary* d = (CCDictionary*)m_lanMap.objectForKey(lan);
    if(!d) {
        d = CCDictionary::create();
        m_lanMap.setObject(d, lan);
    }

    // if not merge, clear first
    if(!merge) {
        d->removeAllObjects();
    }

    // parse it
    CCAndroidStringsParser::create()->parse(path, *d);
}
开发者ID:huaqiangs,项目名称:cocos2dx-common,代码行数:26,代码来源:CCLocalization.cpp

示例2: initWithImageData


//.........这里部分代码省略.........
	if (!textureAtlasNode->count())
	{
		return false;
	}

	CCDictionary * atlasDictionary = (CCDictionary *)textureAtlasNode->objectAtIndex(0);
	float atlasScale = atlasScaleFromAtlasConfig(atlasDictionary);
	for (int i = 1; i < textureAtlasNode->count(); ++i)
	{
		CCDictionary * a = (CCDictionary *)textureAtlasNode->objectAtIndex(i);
		float as = atlasScaleFromAtlasConfig(a);
		if ( fabs(atlasScale - _currentDeviceScale) > fabs(as - _currentDeviceScale))
		{
			atlasDictionary = a;
			atlasScale = as;
		}
	}
	
	_usedAtlasContentScaleFactor = atlasScale;
	CCArray * atlasesInfo = (CCArray *)atlasDictionary->objectForKey(kAtlasInfoKey);
	if (!atlasesInfo)
	{
		GAFLOGERROR("Error while creating GAFAsset.atlasesInfo subnode is missing in atlasDictionary.");
		return false;
	}
	
	_textureAtlas = GAFTextureAtlas::create(fp.c_str(), atlasDictionary);
	if (!_textureAtlas)
	{
		GAFLOGERROR("Failed to initialize GAFAsset. GAFTextureAtlas could not be created.");
		return false;
	}
	CC_SAFE_RETAIN(_textureAtlas);
	
	if (_objects != objectNodes)
	{
		CC_SAFE_RELEASE(_objects);
		_objects = objectNodes;
		CC_SAFE_RETAIN(_objects);
	}
	
	if (_masks != masksNodes)
	{
		CC_SAFE_RELEASE(_masks);
		_masks	  = masksNodes;
		CC_SAFE_RETAIN(_masks);
	}
	
	if (_namedParts != namedPartsNodes)
	{
		CC_SAFE_RELEASE(_namedParts);
		_namedParts	  = namedPartsNodes;
		CC_SAFE_RETAIN(_namedParts);
	}
	
	if (interactionObjectNodes)
	{
		CC_SAFE_RELEASE(_interactionObjects);
		_interactionObjects = CCArray::create();
		CC_SAFE_RETAIN(_interactionObjects);
		
		for (unsigned int i = 0; i < interactionObjectNodes->count(); ++i)
		{
			CCDictionary * dict = (CCDictionary*)interactionObjectNodes->objectAtIndex(i);
			
			GAFInteractionObject * interObject = GAFInteractionObject::create(dict);
			if (interObject)
			{
				_interactionObjects->addObject(interObject);
			}
		}
	}
	
	if (standObjectsNodes)
	{
		CC_SAFE_RELEASE(_standObjects);
		_standObjects = CCArray::create();
		CC_SAFE_RETAIN(_standObjects);
		
		for (unsigned int i = 0; i < standObjectsNodes->count(); ++i)
		{
			CCDictionary * dict = (CCDictionary*)standObjectsNodes->objectAtIndex(i);
			
			GAFActionObject * interObject = GAFActionObject::create(dict);
			if (interObject)
			{
				_standObjects->addObject(interObject);
			}
		}
	}
	
	loadFramesFromConfigDictionary(configDictionary);
	
	if (animationSequences)
	{
		loadAnimationSequences(animationSequences);
	}
	configDictionary->removeAllObjects();
	return true;
}
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:101,代码来源:GAFAsset.cpp

示例3: init

bool TollgateMapLayer::init() {
    bool bRet = false;

    do {
        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

        /* 读取关卡配置 */
        loadConfig();

		/* 加载怪物队列数量 */
		CCString* sMonsterListPath = CCString::createWithFormat("%slevel_%d_others.plist",CCFileUtils::sharedFileUtils()->getWritablePath().c_str(), m_iCurLevel);
	
		if(!CCFileUtils::sharedFileUtils()->isFileExist(sMonsterListPath->getCString()))
		{
			sMonsterListPath = CCString::createWithFormat("tollgate/level_%d_others.plist", m_iCurLevel);
		}
		tinyxml2::XMLDocument * xmlDoc = new tinyxml2::XMLDocument();
		unsigned char* pBuffer = NULL;
		unsigned long bufferSize = 0;

		pBuffer = CCFileUtils::sharedFileUtils()->getFileData(sMonsterListPath->getCString(), "r", &bufferSize);

		if (pBuffer)
		{
			xmlDoc->Parse((const char*)pBuffer);
			CCString* nums = CCString::create(xmlDoc->RootElement()->FirstChildElement()->FirstChildElement()->GetText());
			m_monsterListNum = nums->intValue();
		}
		delete xmlDoc;

		
		/* 创建怪物管理器 */
		m_monsterMgrList = CCArray::createWithCapacity(m_monsterListNum);
		CC_SAFE_RETAIN(m_monsterMgrList);
		for(int i = 0; i < m_monsterListNum; i++){
			m_monsterMgrList->insertObject(MonsterManager::createWithLevel(m_iCurLevel, i), i);
			this->addChild((MonsterManager*)m_monsterMgrList->objectAtIndex(i), MONSTER_LAYER_LVL);
		}
		
		/* 创建英雄管理器 */
		m_heroMgr = HeroManager::createWithLevel(m_iCurLevel);
		this->addChild(m_heroMgr, HERO_LAYER_LVL);

        /* 创建起始点 */
        createStartPoint();

        /* 创建堡垒 */
        createHome();
		
        /* 初始化塔魂、怪物和魔力数量 */
        CCDictionary* dict = CCDictionary::create();

        dict->setObject(CCInteger::create(5), enMsgDataKey_TowerSoulNum);
        NOTIFY->postNotification("TowerSoulChange", dict);

        dict->removeAllObjects();
		CCObject* it = NULL;
		int NotShowMonster = 0;
		CCARRAY_FOREACH(m_monsterMgrList, it){
			MonsterManager* m_monsterMgr = dynamic_cast<MonsterManager*>(it);
			NotShowMonster += m_monsterMgr->getNotShowMonsterCount();
		}
		dict->setObject(CCInteger::create(NotShowMonster), enMsgDataKey_MonsterNum);
        //dict->setObject(CCInteger::create(m_monsterMgr->getNotShowMonsterCount()), enMsgDataKey_MonsterNum);
        NOTIFY->postNotification("MonsterNumChange", dict);

        dict->removeAllObjects();
        dict->setObject(CCInteger::create(100), enMsgDataKey_MagicNum);
        NOTIFY->postNotification("MagicChange", dict);

		dict->removeAllObjects();
        dict->setObject(CCInteger::create(3), enMsgDataKey_MagicNum);
		NOTIFY->postNotification("MonsterListNumChange", dict);

		NOTIFY->addObserver(this, 
			callfuncO_selector(TollgateMapLayer::removeMonsterList), 
			"AllMonsterDead", 
		NULL);

        bRet = true;

    } while (0);
开发者ID:ruozigongzuoshi,项目名称:goddessemblem,代码行数:82,代码来源:TollgateMapLayer.cpp


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