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


C++ CCDictElement::getStrKey方法代码示例

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


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

示例1: loadConfigFile

//
// load file
//
void CCConfiguration::loadConfigFile( const char *filename )
{
	CCDictionary *dict = CCDictionary::createWithContentsOfFile(filename);
	CCAssert(dict, "cannot create dictionary");

	// search for metadata
	bool metadata_ok = false;
	CCObject *metadata = dict->objectForKey("metadata");
	if( metadata && dynamic_cast<CCDictionary*>(metadata) ) {
		CCObject *format_o = static_cast<CCDictionary*>(metadata)->objectForKey("format");

		// XXX: cocos2d-x returns CCStrings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
		if( format_o && dynamic_cast<CCString*>(format_o) ) {
			int format = static_cast<CCString*>(format_o)->intValue();

			// Support format: 1
			if( format == 1 ) {
				metadata_ok = true;
			}
		}
		// XXX: cocos2d-x returns CCStrings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
		if( format_o && dynamic_cast<CCInteger*>(format_o) ) {
			int format = dynamic_cast<CCInteger*>(format_o)->getValue();

			// Support format: 1
			if( format == 1 ) {
				metadata_ok = true;
			}
		}
	}

	if( ! metadata_ok ) {
		CCLOG("Invalid config format for file: %s", filename);
		return;
	}

	CCObject *data = dict->objectForKey("data");
	if( !data || !dynamic_cast<CCDictionary*>(data) ) {
		CCLOG("Expected 'data' dict, but not found. Config file: %s", filename);
		return;
	}

	// Add all keys in the existing dictionary
	CCDictionary *data_dict = static_cast<CCDictionary*>(data);
    CCDictElement* element;
    CCDICT_FOREACH(data_dict, element)
    {
		if( ! m_pValueDict->objectForKey( element->getStrKey() ) )
			m_pValueDict->setObject(element->getObject(), element->getStrKey() );
		else
			CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
    }
}
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:56,代码来源:CCConfiguration.cpp

示例2: loadConfigFile

//
// load file
//
void CCConfiguration::loadConfigFile( const char *filename )
{
	CCDictionary *dict = CCDictionary::createWithContentsOfFile(filename);
	CCAssert(dict, "cannot create dictionary");

	// Add all keys in the existing dictionary
    CCDictElement* element;
    CCDICT_FOREACH(dict, element)
    {
		if( ! m_pDefaults->objectForKey( element->getStrKey() ) )
			m_pDefaults->setObject(element->getObject(), element->getStrKey() );
		else
			CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
    }
}
开发者ID:Cellule,项目名称:RazerGameTech,代码行数:18,代码来源:CCConfiguration.cpp

示例3: visit

void CCPrettyPrinter::visit(const CCDictionary *p)
{
    _result += "\n";
    _result += _indentStr;
    _result += "<dict>\n";
    
    setIndentLevel(_indentLevel+1);
    CCDictElement* element;
    bool bFirstElement = true;
    char buf[1000] = {0};
    CCDICT_FOREACH(p, element)
    {
        if (!bFirstElement) {
            _result += "\n";
        }
        sprintf(buf, "%s%s: ", _indentStr.c_str(),element->getStrKey());
        _result += buf;
        CCPrettyPrinter v(_indentLevel);
        element->getObject()->acceptVisitor(v);
        _result += v.getResult();
        bFirstElement = false;
    }
    setIndentLevel(_indentLevel-1);
    
    _result += "\n";
    _result += _indentStr;
    _result += "</dict>";
}
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:28,代码来源:CCDataVisitor.cpp

示例4: saveDictionary

bool CCDictionarySaver::saveDictionary(CCDictionary* pDict, xmlNodePtr node)
{
    do
    {
        xmlNodePtr dict_node = xmlNewNode(NULL, DICT_NODE_DICT);
        CC_BREAK_IF(!dict_node);
        
        CC_BREAK_IF(!xmlAddChild(node, dict_node));
        
        CCDictElement* pElem;
        CCDICT_FOREACH(pDict, pElem)
        {
            saveKey(pElem->getStrKey(), dict_node);
            
            CCObject* obj = pElem->getObject();

            if (dynamic_cast<CCString*>(obj))
            {
                CCString* s = dynamic_cast<CCString*>(obj);
                CC_BREAK_IF(!saveString(s->getCString(), dict_node));
            }
            else if (dynamic_cast<CCDictionary*>(obj))
            {
                CC_BREAK_IF(!saveDictionary(dynamic_cast<CCDictionary*>(obj), dict_node));
            }
            else if (dynamic_cast<CCArray*>(obj))
            {
                CC_BREAK_IF(!saveArray(dynamic_cast<CCArray*>(obj), dict_node));
            }
        }
        return true;
    } while (false);
开发者ID:raymondma,项目名称:EliminationPlane,代码行数:32,代码来源:CCDictionarySaver.cpp

示例5: addTexts

void YHLanguageManager::addTexts(cocos2d::CCDictionary * dict)
{
    CCDictElement * e = nullptr;
    CCDICT_FOREACH(dict, e)
    {
        m_dict->setObject(e->getObject(), e->getStrKey());
    }
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:7,代码来源:YHLanguageManager.cpp

示例6: handleResponse

void StatusPush::handleResponse(__Dictionary* dict)
{
    if (!dict)
    {
        return;
    }
    __Dictionary* params = _dict(dict->objectForKey("params"));

    if (params->objectForKey("oldStatus")) {//删除该状态的作用
        int reStatusId = params->valueForKey("oldStatus")->intValue();
        if (GlobalData::shared()->statusMap.find(reStatusId) != GlobalData::shared()->statusMap.end()) {
            GlobalData::shared()->statusMap[reStatusId] = 0;
        }
    }
//    int tempTime = 0;
    if (params->objectForKey("effectState")) {
        auto stateDict = _dict(params->objectForKey("effectState"));
        CCDictElement* element;
        CCDICT_FOREACH(stateDict, element)
        {
            string key = element->getStrKey();
//            int effectId = atoi(key.c_str());

            double time = stateDict->valueForKey(key)->doubleValue()/1000;
            if (time>0) {
                time = GlobalData::shared()->changeTime(time);
            }
            if (key!="startTime") {
                GlobalData::shared()->statusMap[atoi(key.c_str())] = -1;//time;
//                tempTime = time;
            }
            map<int, CCDictionary* >::iterator it = ToolController::getInstance()->m_statusItems.find(100);
            CCObject* obj = element->getObject();
            CCString* str = (CCString*)obj;

            if(it!=ToolController::getInstance()->m_statusItems.end()){
                auto dic = it->second;
                if(!dic->objectForKey("startTime")){
                    dic->setObject(CCString::create(CC_ITOA(WorldController::getInstance()->getTime())), "startTime");
                }else if(key!="" && key!="startTime"){
                    dic->setObject(CCString::create(str->getCString()), "endTime");
                }else if(key=="startTime"){
                    dic->setObject(CCString::create(str->getCString()), "startTime");
                }
                ToolController::getInstance()->m_statusItems[100] = dic;
            }else{
                auto infoDic = CCDictionary::create();
                infoDic->retain();
                if(key!="" && key!="startTime"){
                    infoDic->setObject(CCString::create(str->getCString()), "endTime");
                }else if(key=="startTime"){
                    infoDic->setObject(CCString::create(str->getCString()), "startTime");
                }
                ToolController::getInstance()->m_statusItems[100] = infoDic;
            }
            

            ToolController::getInstance()->checkMaincityCustom();

        }
开发者ID:ourgames,项目名称:dc208,代码行数:60,代码来源:ShowStatusItemCommand.cpp

示例7: snapshotTextures

CCDictionary* CCTextureCache::snapshotTextures()
{ 
    CCDictionary* pRet = new CCDictionary();
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_pTextures, pElement)
    {
        pRet->setObject(pElement->getObject(), pElement->getStrKey());
    }
开发者ID:walklook,项目名称:ThreadTile,代码行数:8,代码来源:CCTextureCache.cpp

示例8: convertDictionaryToJson

void CCJSONConverter::convertDictionaryToJson(CCDictionary *dictionary, cJSON *json)
{
    CCDictElement * pElement = NULL;
    CCDICT_FOREACH(dictionary, pElement){
        CCObject * obj = pElement->getObject();
        cJSON * jsonItem = getObjJson(obj);
        cJSON_AddItemToObject(json, pElement->getStrKey(), jsonItem);
    }
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:8,代码来源:CCJSONConverter.cpp

示例9: addEffectDefiner

void YHEffectFactory::addEffectDefiner(CCDictionary * dict)
{
	CCDictElement * e = NULL;
	CCDICT_FOREACH(dict, e)
	{
		YHEffectDefiner * definer = new YHEffectDefiner((CCDictionary *)e->getObject());
		definer->autorelease();
		addEffectDefiner(e->getStrKey(), definer);
	}
开发者ID:bontey,项目名称:cocos2d-x-tools,代码行数:9,代码来源:YHEffectGenerator.cpp

示例10: ccTouchBegan

bool Cartoon::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event)
{
    CCPoint touchLocation = touch->getLocationInView();
    touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
    touchLocation = convertToNodeSpace(touchLocation);
    
    // from left-bottom point to from left-top point
    touchLocation.y = getContentSize().height - touchLocation.y;
    
    if (m_pListener && m_pfnSelector) {
        CCDictElement* pElement = NULL;
        CCDICT_FOREACH(m_pBoxConfigs, pElement)
        {
            CCString *psBox = (CCString*)pElement->getObject();
            CCRect rectOfTouched = CCRectFromString(psBox->m_sString.c_str());
            if (rectOfTouched.containsPoint(touchLocation) && getBoxEnabled(pElement->getStrKey())) {
                (m_pListener->*m_pfnSelector)(this, pElement->getStrKey());
            }
        }
开发者ID:echenonline,项目名称:Blackcat,代码行数:19,代码来源:Cartoon.cpp

示例11: initNpcNames

// initialize NPC names
void NPCManager::initNpcNames()
{
	// read NpcName.plist
	const char* pszPath = GameResourceManager::sharedManager()->storedFullPathFromRelativePath(NPC_NAME_PLIST);
	CCDictionary *pNameDict = CCFileUtils::dictionaryWithContentsOfFile(pszPath);

	CCDictElement* pElement = NULL;
	CCDICT_FOREACH(pNameDict, pElement)
	{
		if (pNameDict->objectForKey(pElement->getStrKey()))
		{
			string strNpcID = pElement->getStrKey();
			string strName = ((CCString*)pElement->getObject())->toStdString();
			uint8 npcID = atoi(strNpcID.c_str());
			m_npcName[npcID] = strName;
		}
	}

}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:20,代码来源:NPCManager.cpp

示例12: CCLOG

void CCAnimationCache::parseVersion1(CCDictionary* animations)
{
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();

    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(animations, pElement)
    {
        CCDictionary* animationDict = (CCDictionary*)pElement->getObject();
        CCArray* frameNames = (CCArray*)animationDict->objectForKey("frames");
        float delay = animationDict->valueForKey("delay")->floatValue();
        CCAnimation* animation = NULL;

        if ( frameNames == NULL ) 
        {
            CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
            continue;
        }

        CCArray* frames = CCArray::createWithCapacity(frameNames->count());
        frames->retain();

        CCObject* pObj = NULL;
        CCARRAY_FOREACH(frameNames, pObj)
        {
            const char* frameName = ((CCString*)pObj)->getCString();
            CCSpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);

            if ( ! spriteFrame ) {
                CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);

                continue;
            }

            CCAnimationFrame* animFrame = new CCAnimationFrame();
            animFrame->initWithSpriteFrame(spriteFrame, 1, NULL);
            frames->addObject(animFrame);
            animFrame->release();
        }

        if ( frames->count() == 0 ) {
            CCLOG("cocos2d: CCAnimationCache: None of the frames for animation '%s' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
            continue;
        } else if ( frames->count() != frameNames->count() ) {
            CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
        }

        animation = CCAnimation::create(frames, delay, 1);

        CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
        frames->release();
    }    
开发者ID:LaughingYan,项目名称:cocos2d-x,代码行数:51,代码来源:CCAnimationCache.cpp

示例13: jsonFromDictionary

Json::Value jsonFromDictionary(CCDictionary * root)
{
	if (root == NULL)
		return Json::Value::null;
    
    if (root->count() == 0)
    {
        Json::Value value;
        Json::Reader reader;
        reader.parse("{}", value);
        return value;
    }
	
	Json::Value jsonNode;
	CCDictElement * e = NULL;
	CCDICT_FOREACH(root, e)
	{
		if (dynamic_cast<CCArray *>(e->getObject()) != NULL)
		{
			Json::Value jsonChild = jsonFromArray((CCArray *)e->getObject());
			jsonNode[e->getStrKey()] = jsonChild;
		}
		else if (dynamic_cast<CCDictionary *>(e->getObject()) != NULL)
		{
			Json::Value jsonChild = jsonFromDictionary((CCDictionary *)e->getObject());
			jsonNode[e->getStrKey()] = jsonChild;
		}
		else if (dynamic_cast<CCString *>(e->getObject()) != NULL)
		{
			Json::Value jsonChild = Json::Value(((CCString *)e->getObject())->getCString());
			jsonNode[e->getStrKey()] = jsonChild;
		}
	}
	
	return jsonNode;
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:36,代码来源:YHJsonHelper.cpp

示例14: isSame

bool AmfUtil::isSame(cocos2d::CCObject *thisObj, cocos2d::CCObject *thatObj) {
    if (thisObj && !thatObj) return false;
    if (!thisObj && thatObj) return false;
    if (!thisObj && !thatObj) return true;

    if (dynamic_cast<CCBool *>(thisObj) && dynamic_cast<CCBool *>(thatObj)) {
        return dynamic_cast<CCBool *>(thisObj)->getValue() == dynamic_cast<CCBool *>(thatObj)->getValue();
    } else if (dynamic_cast<CCInteger *>(thisObj) && dynamic_cast<CCInteger *>(thatObj)) {
        return dynamic_cast<CCInteger *>(thisObj)->getValue() == dynamic_cast<CCInteger *>(thatObj)->getValue();
    } else if (dynamic_cast<CCFloat *>(thisObj) && dynamic_cast<CCFloat *>(thatObj)) {
        return dynamic_cast<CCFloat *>(thisObj)->getValue() == dynamic_cast<CCFloat *>(thatObj)->getValue();
    } else if (dynamic_cast<CCDouble *>(thisObj) && dynamic_cast<CCDouble *>(thatObj)) {
        return dynamic_cast<CCDouble *>(thisObj)->getValue() == dynamic_cast<CCDouble *>(thatObj)->getValue();
    } else if (dynamic_cast<CCString *>(thisObj) && dynamic_cast<CCString *>(thatObj)) {
        return strcmp(dynamic_cast<CCString *>(thisObj)->getCString(), dynamic_cast<CCString *>(thatObj)->getCString()) == 0;
    } else if (dynamic_cast<CCDate *>(thisObj) && dynamic_cast<CCDate *>(thatObj)) {
        return dynamic_cast<CCDate *>(thisObj)->isEqual(dynamic_cast<CCDate *>(thatObj));
    } else if (dynamic_cast<AmfTraitsInfo *>(thisObj) && dynamic_cast<AmfTraitsInfo *>(thatObj)) {
        return dynamic_cast<AmfTraitsInfo *>(thisObj)->isEqual(dynamic_cast<AmfTraitsInfo *>(thatObj));
    } else if (dynamic_cast<AmfObject *>(thisObj) && dynamic_cast<AmfObject *>(thatObj)) {
        return dynamic_cast<AmfObject *>(thisObj)->isEqual(dynamic_cast<AmfObject *>(thatObj));
    } else if (dynamic_cast<AmfCoding *>(thisObj) && dynamic_cast<AmfCoding *>(thatObj)) {
        return dynamic_cast<AmfCoding *>(thisObj)->isEquals(thatObj);
    } else if (dynamic_cast<CCArray *>(thisObj) && dynamic_cast<CCArray *>(thatObj)) {
        CCArray *thisArray = dynamic_cast<CCArray *>(thisObj);
        CCArray *thatArray = dynamic_cast<CCArray *>(thatObj);
        int count = thisArray->count();
        int capacity = thisArray->capacity();
        if (count != thatArray->count() || (count == 0 && capacity != thatArray->capacity()))
            return false;
        for (int i = 0; i < count; i++) {
            if (!isSame(thisArray->objectAtIndex(i), thatArray->objectAtIndex(i)))
                return false;
        }
        return true;
    } else if (dynamic_cast<CCDictionary *>(thisObj) && dynamic_cast<CCDictionary *>(thatObj)) {
        CCDictionary *thisDict = dynamic_cast<CCDictionary *>(thisObj);
        CCDictionary *thatDict = dynamic_cast<CCDictionary *>(thatObj);
        int count = thisDict->count();
        if (count != thatDict->count())
            return false;
        CCDictElement *thisElement;
        CCDICT_FOREACH(thisDict, thisElement) {
                char const *thisKey = thisElement->getStrKey();
                CCObject *thatValue = thatDict->objectForKey(thisKey);
                if (!thatValue) return false;
                if (!isSame(thisElement->getObject(), thatValue)) return false;
            }
开发者ID:cpascal,项目名称:Cocos2dx-AMF3,代码行数:48,代码来源:AmfUtil.cpp

示例15: removeUnusedAnimations

void ArmatureDataManager::removeUnusedAnimations(){
    if( m_pArmatureFileInfoDic ){
        CCTextureCache * tc = CCTextureCache::sharedTextureCache();
        CCSpriteFrameCache * sfc = CCSpriteFrameCache::sharedSpriteFrameCache();
        std::vector<std::string> cleanlist;
        CCDictElement* pElement = NULL;
        CCDICT_FOREACH(m_pArmatureFileInfoDic, pElement){
            const std::string file = pElement->getStrKey();
            ArmatureFileInfo * _fileInfo = (ArmatureFileInfo*)pElement->getObject();
            if (_fileInfo && _fileInfo->retainCount() == 1) {
                
                //清理 m_pAnimationDatas、m_pArmarureDatas、m_pTextureDatas 信息
                if( m_pAnimationDatas ){
                    m_pAnimationDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                if( m_pArmarureDatas ){
                    m_pArmarureDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                if( m_pTextureDatas ){
                    m_pTextureDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                //清理精灵帧、纹理和标记需要清理的ArmatureFile
                for (std::vector<ImageInfo>::iterator it = _fileInfo->imageInfoVector.begin();
                     it != _fileInfo->imageInfoVector.end();
                     it++){
                    const std::string & plist = it->plistPath;
                    const std::string & texture = it->imagePath;
                    sfc->removeSpriteFramesFromFile(plist.c_str());
                    tc->removeTextureForKey(texture.c_str());
                    cleanlist.push_back(file);
                }
            }
        }
        
        
        
        int size = cleanlist.size();
        for(int i = 0; i < size; i++) {
            m_pArmatureFileInfoDic->removeObjectForKey(cleanlist[i]);
        }
        cleanlist.clear();
    }
}
开发者ID:xbinglzh,项目名称:my1netFrameWork,代码行数:46,代码来源:SPArmatureDataManager.cpp


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