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


C++ DictElement类代码示例

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


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

示例1: addChild

void BatchNode::addChild(Node *child, int zOrder, int tag)
{
    Node::addChild(child, zOrder, tag);
    Armature *armature = dynamic_cast<Armature *>(child);
    if (armature != nullptr)
    {
        armature->setBatchNode(this);

        const Dictionary *dict = armature->getBoneDic();
        DictElement *element = nullptr;
        CCDICT_FOREACH(dict, element)
        {
            Bone *bone = static_cast<Bone*>(element->getObject());

            Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
            for(auto object : *displayList)
            {
                DecorativeDisplay *display = static_cast<DecorativeDisplay*>(object);
                                
                if (Skin *skin = dynamic_cast<Skin*>(display->getDisplay()))
                {
                    skin->setTextureAtlas(getTexureAtlasWithTexture(skin->getTexture()));
                }
            }
        }
开发者ID:CryQ,项目名称:coclua,代码行数:25,代码来源:CCBatchNode.cpp

示例2: log

void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response)
{
	log("SIOClientImpl::handshakeResponse() called");

	if (0 != strlen(response->getHttpRequest()->getTag())) 
    {
        log("%s completed", response->getHttpRequest()->getTag());
    }

	int statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
	log("response code: %d", statusCode);

	if (!response->isSucceed()) 
    {
        log("SIOClientImpl::handshake() failed");
        log("error buffer: %s", response->getErrorBuffer());

		DictElement* el = NULL;

		CCDICT_FOREACH(_clients, el) {

			SIOClient* c = static_cast<SIOClient*>(el->getObject());
			
			c->getDelegate()->onError(c, response->getErrorBuffer());

		}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:28,代码来源:SocketIO.cpp

示例3: setIndentLevel

void PrettyPrinter::visit(const __Dictionary *p)
{
    _result += "\n";
    _result += _indentStr;
    _result += "<dict>\n";
    
    setIndentLevel(_indentLevel+1);
    DictElement* 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;
        PrettyPrinter v(_indentLevel);
//FIXME:james        element->getObject()->acceptVisitor(v);
        _result += v.getResult();
        bFirstElement = false;
    }
    setIndentLevel(_indentLevel-1);
    
    _result += "\n";
    _result += _indentStr;
    _result += "</dict>";
}
开发者ID:bonlai,项目名称:3kaigame,代码行数:28,代码来源:CCDataVisitor.cpp

示例4: Dictionary

Dictionary* TextureCache::snapshotTextures()
{ 
    Dictionary* pRet = new Dictionary();
    DictElement* pElement = NULL;
    CCDICT_FOREACH(_textures, pElement)
    {
        pRet->setObject(pElement->getObject(), pElement->getStrKey());
    }
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:8,代码来源:CCTextureCache.cpp

示例5: convertDictionaryToJson

void CCJSONConverter::convertDictionaryToJson(__Dictionary *Dictionary, cJSON *json)
{
#if COCOS2D_VERSION >= 0x00030000
    DictElement * pElement = NULL;
#else
    CCDictElement * pElement = NULL;
#endif
    CCDICT_FOREACH(Dictionary, pElement){
        Ref * obj = pElement->getObject();
        cJSON * jsonItem = getObjJson(obj);
        cJSON_AddItemToObject(json, pElement->getStrKey(), jsonItem);
    }
开发者ID:JackTongy,项目名称:shared,代码行数:12,代码来源:CCJSONConverter.cpp

示例6: CCLOG

void AnimationCache::parseVersion1(Dictionary* animations)
{
    SpriteFrameCache *frameCache = SpriteFrameCache::sharedSpriteFrameCache();

    DictElement* pElement = NULL;
    CCDICT_FOREACH(animations, pElement)
    {
        Dictionary* animationDict = (Dictionary*)pElement->getObject();
        Array* frameNames = (Array*)animationDict->objectForKey("frames");
        float delay = animationDict->valueForKey("delay")->floatValue();
        Animation* animation = NULL;

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

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

        Object* pObj = NULL;
        CCARRAY_FOREACH(frameNames, pObj)
        {
            const char* frameName = ((String*)pObj)->getCString();
            SpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);

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

                continue;
            }

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

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

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

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

示例7: CCASSERT

//
// load file
//
void Configuration::loadConfigFile(const char *filename)
{
	Dictionary *dict = Dictionary::createWithContentsOfFile(filename);
	CCASSERT(dict, "cannot create dictionary");

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

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

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

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

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

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

示例8: setPreferredSize

void ControlButton::setPreferredSize(Size size)
{
    if(size.width == 0 && size.height == 0)
    {
        _doesAdjustBackgroundImage = true;
    }
    else
    {
        _doesAdjustBackgroundImage = false;
        DictElement * item = NULL;
        CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
        {
            Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
            sprite->setPreferredSize(size);
        }
    }
开发者ID:henyouqian,项目名称:cocos2d-x-3.0alpha0,代码行数:16,代码来源:CCControlButton.cpp

示例9: PreSolve

void OneSidedPlatform::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
    Test::PreSolve(contact, oldManifold);
    
    b2Fixture* fixtureA = contact->GetFixtureA();
    b2Fixture* fixtureB = contact->GetFixtureB();
    
    DictElement * ele;
    __Dictionary * itemList = BattleController::shared()->getItemList();
    CCDICT_FOREACH(itemList, ele){
        Item * item = dynamic_cast<Item*>(ele->getObject());
        b2Fixture * itemBox2d = item->getB2fixture();
        if (fixtureA == itemBox2d || fixtureB == itemBox2d) {
            contact->SetEnabled(false);
            break;
        }
    }
开发者ID:fordream,项目名称:Snake,代码行数:17,代码来源:OneSidePlatform.cpp

示例10: foreach

//遍历
void CommonDictionary::foreach()
{
	DictElement * pElement;
	CCDICT_FOREACH(pDict, pElement) 
	{
		const char * key = pElement->getStrKey();

		const char* value = (const char*)pDict->objectForKey(key);

		printf("CommonDictionary ---> key = %s, value = %s\n", key, value);

		//CCLog(key);
		//CCLog(value);
		//myStrcat(Str, value);
 		//CCLog(Str);
	}
}
开发者ID:quinsmpang,项目名称:mlua,代码行数:18,代码来源:CommonDictionary.cpp

示例11: CC_SAFE_RETAIN

Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &parentSize)
{
    mData = pData;
    CC_SAFE_RETAIN(mData);
    mBytes = mData->getBytes();
    mCurrentByte = 0;
    mCurrentBit = 0;
    mOwner = pOwner;
    CC_SAFE_RETAIN(mOwner);

    mActionManager->setRootContainerSize(parentSize);
    mActionManager->mOwner = mOwner;
    mOwnerOutletNodes = new Array();
    mOwnerCallbackNodes = new Array();
    
    Dictionary* animationManagers = Dictionary::create();
    Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
    
    if (pNodeGraph && mActionManager->getAutoPlaySequenceId() != -1 && !jsControlled)
    {
        // Auto play animations
        mActionManager->runAnimationsForSequenceIdTweenDuration(mActionManager->getAutoPlaySequenceId(), 0);
    }
    // Assign actionManagers to userObject
    if(jsControlled) {
        mNodesWithAnimationManagers = new Array();
        mAnimationManagersForNodes = new Array();
    }
    
    DictElement* pElement = NULL;
    CCDICT_FOREACH(animationManagers, pElement)
    {
        Node* pNode = (Node*)pElement->getIntKey();
        CCBAnimationManager* manager = static_cast<CCBAnimationManager*>(animationManagers->objectForKey((intptr_t)pNode));
        pNode->setUserObject(manager);

        if (jsControlled)
        {
            mNodesWithAnimationManagers->addObject(pNode);
            mAnimationManagersForNodes->addObject(manager);
        }
    }
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:42,代码来源:CCBReader.cpp

示例12: setAnimationScale

void ArmatureAnimation::setAnimationScale(float animationScale )
{
    if(animationScale == _animationScale)
    {
        return;
    }

    _animationScale = animationScale;

    DictElement *element = NULL;
    Dictionary *dict = _armature->getBoneDic();
    CCDICT_FOREACH(dict, element)
    {
        Bone *bone = (Bone *)element->getObject();
        bone->getTween()->setAnimationScale(_animationScale);
        if (bone->getChildArmature())
        {
            bone->getChildArmature()->getAnimation()->setAnimationScale(_animationScale);
        }
    }
开发者ID:Ratel13,项目名称:HXGame,代码行数:20,代码来源:CCArmatureAnimation.cpp

示例13: dictionaryToMap

static void dictionaryToMap(__Dictionary* dict, map<string,string>& ret)
{
	if (dict == nullptr)
		return;
	
	DictElement* el = nullptr;
	CCDICT_FOREACH(dict, el)
	{
		auto str = dynamic_cast<__String*>(el->getObject());
		auto boolean = dynamic_cast<__Bool*>(el->getObject());
		auto number = dynamic_cast<__Double*>(el->getObject());
		stringstream ss;
		if (str)
			ss << str->getCString();
		else if (boolean)
			ss << (int)boolean->getValue();
		else if (number)
			ss << number->getValue();
		ret[el->getStrKey()] = ss.str();
	}
开发者ID:NatWeiss,项目名称:RGP,代码行数:20,代码来源:jsb_facebook.cpp

示例14: setSpeedScale

void ArmatureAnimation::setSpeedScale(float speedScale)
{
    if(speedScale == _speedScale)
    {
        return;
    }

    _speedScale = speedScale;

    _processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale;

    DictElement *element = NULL;
    Dictionary *dict = _armature->getBoneDic();
    CCDICT_FOREACH(dict, element)
    {
        Bone *bone = static_cast<Bone*>(element->getObject());

        bone->getTween()->setProcessScale(_processScale);
        if (bone->getChildArmature())
        {
            bone->getChildArmature()->getAnimation()->setProcessScale(_processScale);
        }
    }
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:23,代码来源:CCArmatureAnimation.cpp

示例15: dictionary_to_rubyval

mrb_value dictionary_to_rubyval(mrb_state* mrb, __Dictionary* dict)
{
    mrb_value rhash = mrb_hash_new(mrb);
    
    DictElement* element = nullptr;
    
    std::string className = "";
    __String* strVal = nullptr;
    __Dictionary* dictVal = nullptr;
    __Array* arrVal = nullptr;
    __Double* doubleVal = nullptr;
    __Bool* boolVal = nullptr;
    __Float* floatVal = nullptr;
    __Integer* intVal = nullptr;
    
    CCDICT_FOREACH(dict, element) {
        if (nullptr == element)
            continue;
        
        mrb_value rkey = mrb_str_new_cstr(mrb, element->getStrKey());
        mrb_value rval;
        std::string typeName = typeid(element->getObject()).name();
        auto iter = g_rubyType.find(typeName);
        if (g_rubyType.end() != iter) {
            className = iter->second;
            if (nullptr != dynamic_cast<Ref*>(element->getObject())) {
                rval = to_mrb_value(mrb, element->getObject());
            }
        } else if((strVal = dynamic_cast<__String *>(element->getObject()))) {
            rval = mrb_str_new_cstr(mrb, strVal->getCString());
        } else if ((dictVal = dynamic_cast<__Dictionary*>(element->getObject()))) {
            rval = dictionary_to_rubyval(mrb, dictVal);
        } else if ((arrVal = dynamic_cast<__Array*>(element->getObject()))) {
            rval = array_to_rubyval(mrb, arrVal);
        } else if ((doubleVal = dynamic_cast<__Double*>(element->getObject()))) {
            rval = mrb_float_value(mrb, (mrb_float)doubleVal->getValue());
        } else if ((floatVal = dynamic_cast<__Float*>(element->getObject()))) {
            rval = mrb_float_value(mrb, (mrb_float)floatVal->getValue());
        } else if ((intVal = dynamic_cast<__Integer*>(element->getObject()))) {
            rval = mrb_fixnum_value((mrb_int)intVal->getValue());
        } else if ((boolVal = dynamic_cast<__Bool*>(element->getObject()))) {
            rval = mrb_bool_value((mrb_bool)boolVal->getValue());
        } else {
            CCASSERT(false, "the type isn't suppored.");
        }
        mrb_hash_set(mrb, rhash, rkey, rval);
    }
    
    return rhash;
}
开发者ID:blackant2,项目名称:mruby-cocos2dx,代码行数:50,代码来源:RubyBasicConversions.cpp


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