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


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

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


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

示例1: onOkClick

void TestFeedBackView::onOkClick(cocos2d::CCObject *pSender, CCControlEvent event)
{
//    if (TESTFEEDBACK_CONTROL->getServerId().length() == 0 || TESTFEEDBACK_CONTROL->getName().length() == 0 ||  TESTFEEDBACK_CONTROL->getServerId() == "0")
//    {
//        CCCommonUtils::flyHint("", "", "请输入服务器号和名字");//todocfb
//        return;
//    }
    //////////点确认按钮单独传递玩家的服务器号和名字,反馈内容在每次填写完面板后已经向后台传递完成
    CCObject* obj = NULL;
    CCDictionary* pelem = NULL;
    CCARRAY_FOREACH(m_data, obj)
    {
        pelem = (CCDictionary*)obj;
        pelem->setObject(ccs("1"), "fixFlag");
        break;//所以只需要每其中一项理性“fixFlag”即可
    }
开发者ID:ourgames,项目名称:dc208,代码行数:16,代码来源:TestFeedBackView.cpp

示例2: setAd

void ThirdPartyHelper::setAd(int tag){
    if (tag == SET_AD_SCREEN) {
        const char *key = "admobscreenad";
        int time = UserDefault::getInstance()->getIntegerForKey(key, SCREEN_AD_TIME);
        if (time !=1 ) {
            UserDefault::getInstance()->setIntegerForKey(key, time-1);
            return;
        }else{
            UserDefault::getInstance()->setIntegerForKey(key, SCREEN_AD_TIME);
        }
    }
    
    CCDictionary *dic = CCDictionary::create();
    dic->setObject(CCString::create(StringUtils::format("%d",tag)), "setAd");
    SendMessageWithParams("setAd", dic);
}
开发者ID:LuckyGameCn,项目名称:LHCocosGame,代码行数:16,代码来源:ThirdPartyHelper.cpp

示例3: LuaArmatureWrapper

static int tolua_Cocos2dx_CCArmatureAnimation_setFrameEventCallFunc00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"CCArmatureAnimation",0,&tolua_err) ||
        !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
        !tolua_isnoobj(tolua_S,3,&tolua_err)
        )
        goto tolua_lerror;
    else
#endif
    {
        CCArmatureAnimation* self = (CCArmatureAnimation*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
        if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFrameEventCallFunc'", NULL);
#endif
        LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
        if (NULL == wrapper)
        {
            tolua_error(tolua_S,"LuaArmatureWrapper create fail\n", NULL);
            return 0;
        }
        
        wrapper->autorelease();
        LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,2,0));
        
        wrapper->setHandler(handler);
        
        CCDictionary* dict = static_cast<CCDictionary*>(self->getUserObject());
        if (NULL == self->getUserObject())
        {
            dict = CCDictionary::create();
            self->setUserObject(dict);
        }
        
        dict->setObject(wrapper, "frameEvent");
        
        self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback));
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err);
    return 0;
#endif
}
开发者ID:237676098,项目名称:quick-cocos2d-x,代码行数:47,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例4: CCDictionary

static int tolua_Cocos2dx_CCTableView_setDataSource(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"CCTableView",0,&tolua_err) ||
        !tolua_isnoobj(tolua_S,2,&tolua_err)
        )
        goto tolua_lerror;
    else
#endif
    {
        CCTableView* self = (CCTableView*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
        if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDataSource'", NULL);
#endif
        LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource();
        if (NULL == dataSource)
            return 0;
        
        CCDictionary* userDict = static_cast<CCDictionary*>(self->getUserObject());
        if (NULL == userDict)
        {
            userDict = new CCDictionary();
            if (NULL == userDict)
                return 0;
            
            self->setUserObject(userDict);
            userDict->release();
        }
        
        userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);
        
        self->setDataSource(dataSource);
        
        dataSource->release();
        
        return 0;
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'setDataSource'.",&tolua_err);
    return 0;
#endif    
}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:46,代码来源:lua_cocos2dx_extensions_manual.cpp

示例5: toucheventselector

static int tolua_Cocos2dx_Widget_addTouchEventListener00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"Widget",0,&tolua_err) ||
        !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
        !tolua_isnoobj(tolua_S,3,&tolua_err)
    )
        goto tolua_lerror;
    else
#endif
    {
        Widget* self = (Widget*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
        if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addTouchEventListener'", NULL);
#endif
        LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
        if (NULL == listener)
        {
            tolua_error(tolua_S,"LuaCocoStudioEventListener create fail\n", NULL);
            return 0;
        }

        LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,2,0));

        listener->setHandler(handler);

        CCDictionary* dict = static_cast<CCDictionary*>(self->getScriptObjectDict());
        if (NULL == dict)
        {
            dict = CCDictionary::create();
            self->setScriptObjectDict(dict);
        }
        dict->setObject(listener, "widgetTouchEvent");

        self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc));
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'addTouchEventListener'.",&tolua_err);
    return 0;
#endif
}
开发者ID:fordream,项目名称:quick,代码行数:45,代码来源:lua_cocos2dx_cocostudio_manual.cpp

示例6: ccTouchesBegan

void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
        CCPoint location = pTouch->getLocation();

        pTouchPoint->setTouchPos(location);
        pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);

        addChild(pTouchPoint);
        s_dic.setObject(pTouchPoint, pTouch->getID());
    }
    

}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:18,代码来源:MutiTouchTest.cpp

示例7: handleTouchesBegin

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
    CCSet set;
    for (int i = 0; i < num; ++i)
    {
        int id = ids[i];
        float x = xs[i];
        float y = ys[i];

        CCInteger* pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
        int nUnusedIndex = 0;

        // it is a new touch
        if (pIndex == NULL)
        {
            nUnusedIndex = getUnUsedIndex();

            // The touches is more than MAX_TOUCHES ?
            if (nUnusedIndex == -1) {
                CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex);
                continue;
            }

            CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fScaleX, 
                                     (y - m_obViewPortRect.origin.y) / m_fScaleY);
            
            //CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
            
            CCInteger* pInterObj = new CCInteger(nUnusedIndex);
            s_TouchesIntergerDict.setObject(pInterObj, id);
            set.addObject(pTouch);
            pInterObj->release();
        }
    }

    if (set.count() == 0)
    {
        CCLOG("touchesBegan: count = 0");
        return;
    }

    m_pDelegate->touchesBegan(&set, NULL);
}
开发者ID:saranpol,项目名称:cocos2d-x,代码行数:44,代码来源:CCEGLViewProtocol.cpp

示例8: menuCloseCallback

void HelloWorld::menuCloseCallback(CCObject* pSender)
{
    // Register a selector in a global space
    // So that when our native environment will call the method with the string
    // It can respond to the selector
    // Note : Group name is there for ease of removing the selectors
    NDKHelper::AddSelector("HelloWorldSelectors",
                           "SampleSelector",
                           callfuncND_selector(HelloWorld::SampleSelector),
                           this);
    
    // Making parameters for message to be passed to native language
    // For the ease of use, i am sending the method to be called name from C++
    CCDictionary* prms = CCDictionary::create();
    prms->setObject(CCString::create("SampleSelector"), "to_be_called");
    
    // Finally call the native method in current environment
    SendMessageWithParams(string("SampleSelector"), prms);
}
开发者ID:AllenCoder,项目名称:EasyNDK-for-cocos2dx,代码行数:19,代码来源:HelloWorldScene.cpp

示例9: bindListener

void SGHttpClient::bindListener(char *buffer)
{
    SGResponseData *rData = new SGResponseData(buffer);
    
    char ch = rData->readChar();
    short type = rData->readShort();
    
    CCString *string1 = CCString::createWithFormat("%d",ch);
    CCString *string2 = CCString::createWithFormat("%d",type);
    CCDictionary *dict = CCDictionary::create();
    dict->setObject(string1, "string1");
    dict->setObject(string2, "string2");
	
    delete rData;
    if(_delegate)
    {
        _delegate->requestFinished(MSG_HTTP_BING, dict);
    }
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:19,代码来源:SGHttpClient.cpp

示例10: setBalsamiqControl

void CCBalsamiqLayer::setBalsamiqControl(const std::string &controlType, const std::string &controlName, CCNode *control)
{
    if (controlType.length() == 0 || controlName.length() == 0)
    {
        return;
    }
    
    CCObject *controlsDic = this->getBalsamiqControlDic()->objectForKey(controlType);
    
    if (controlsDic == NULL)
    {
        CCDictionary *dic = CCDictionary::create();
        dic->setObject(control, controlName);
        this->getBalsamiqControlDic()->setObject(dic, controlType);
    }
    else
    {
        static_cast<CCDictionary *>(controlsDic)->setObject(control, controlName);
    }
}
开发者ID:livingyang,项目名称:BalsamiqXmlReader-x,代码行数:20,代码来源:CCBalsamiqLayer.cpp

示例11: onEnter

void TestFilenameLookup::onEnter()
{
    FileUtilsDemo::onEnter();
		
    CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();

    CCDictionary *dict = CCDictionary::create();
    dict->setObject(CCString::create("Images/grossini.png"), "grossini.bmp");
    dict->setObject(CCString::create("Images/grossini.png"), "grossini.xcf");
    
    sharedFileUtils->setFilenameLookupDictionary(dict);
    
    
    // Instead of loading carlitos.xcf, it will load grossini.png
    CCSprite *sprite = CCSprite::create("grossini.xcf");
    this->addChild(sprite);
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    sprite->setPosition(ccp(s.width/2, s.height/2));
}
开发者ID:PavolSatala,项目名称:cocos2d-x,代码行数:20,代码来源:FileUtilsTest.cpp

示例12: sqliteExecCallBack

int GlobalData::sqliteExecCallBack( void * para, int n_column, char ** column_value, char ** column_name )
{
    const char *myPara = (const char *)para;

    if (strcmp(myPara, QUERY_CATEGORY_FRACTION)==0) {
        CCDictionary *dict = CCDictionary::create();
        for(int i = 0 ; i < n_column; i ++ )
        {
            dict->setObject(CCString::create(column_value[i]), column_name[i]);
        }
        arrayFraction->addObject(dict);
    } else if(strcmp(myPara, QUERY_CATEGORY_CARDINFO)==0) {
        dictCard = CCDictionary::create();
        for(int i = 0 ; i < n_column; i ++ )
        {
            dictCard->setObject(CCString::create(column_value[i]), column_name[i]);
        }
	} else if(strcmp(myPara, QUERY_CATEGORY_CARDBYGROUP)==0) {
		dictCard = CCDictionary::create();
		for(int i = 0 ; i < n_column; i ++ )
		{
			dictCard->setObject(CCString::create(column_value[i]), column_name[i]);
		}
		arrayCardProfile->addObject(dictCard);
	} else if(strcmp(myPara, QUERY_CARD_PROFILE_BY_NAME)==0) {
		dictCard = CCDictionary::create();
		for(int i = 0 ; i < n_column; i ++ )
		{
			dictCard->setObject(CCString::create(column_value[i]), column_name[i]);
		}
	} else if(strcmp(myPara, QUERY_CARD_PROFILE_ALL)==0) {
		dictCard = CCDictionary::create();
		for(int i = 0 ; i < n_column; i ++ )
		{
			dictCard->setObject(CCString::create(column_value[i]), column_name[i]);
		}
		arrayCards->addObject(dictCard);
	}

    return 0;
}
开发者ID:crazyit,项目名称:iGame,代码行数:41,代码来源:GlobalData.cpp

示例13: editBoxEditingDidEnd

void InputLabel::editBoxEditingDidEnd(ui::EditBox* editBox)
{
    CCLOG("Edit Box editing did end");
    if(isOpened)
    { //on dealloc, the isOpened flag will be false to prevent this code from being executed (could be used for a cancel method too)
        isOpened = false;
        if(linkTo != NULL)
        {
            if(strlen(delegate->getText()) > 0)
            {
                if(isPassword)
                {
                    IFEXIST(passwordText)->autorelease();
                    passwordText = new CCString(delegate->getText());
                    std::string bulletString;
                    for(int i = 0; i < (int)strlen(delegate->getText()); i++)
                    {
                        bulletString.append("●");
                    }
                    linkTo->setLabelValue(bulletString.c_str());
                }
                else
                {
                    linkTo->setLabelValue(delegate->getText());
                }
            }
            else
            {
                linkTo->setLabelValue(initialText->getCString());
            }
            delegate->setText("");
            linkTo->setVisible(true);
        }
        CCDictionary* param = this->getEventInfos();
        param->setObject(Screate(this->getLabelValue()), "Text");
        Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("TextAdded", param);
    }
    delegate->detachWithIME();
}
开发者ID:poplax,项目名称:FenneXEmptyProject,代码行数:39,代码来源:InputLabel.cpp

示例14: simulateAnswerRight

void QuestionLayer::simulateAnswerRight()
{
    this->unschedule(schedule_selector(QuestionLayer::timerCB));

    CCDictionary* results = questionObj->rightAnswer;
    for (int i=0; i<results->allKeys()->count(); i++) {
        CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
        results->setObject(CCString::createWithFormat("%d", 1), key->getCString());
    }

    //回答完成所有正确答案
    for (int i=0; i<results->allKeys()->count(); i++) {
        CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
        CCControlButton* btn = (CCControlButton *)(this->getChildByTag(key->intValue()));
        CCSprite* spr = CCSprite::create("star000.png");
        spr->setAnchorPoint(ccp(0.5f, 0.5f));
        spr->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
        btn->addChild(spr);
        CCBlink* blink = CCBlink::create(1.0f, 3);
        if (i < results->allKeys()->count()-1) {
            spr->runAction(blink);
        } else {
            CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
            spr->runAction(CCSequence::create(blink, pAction, NULL));
        }
    }

    rightAnswer++;
    if (timerCount >= timerTotal*2/3) {
        rightLimit += 1;
        //播放快速答题音效
        GameSoundManager::shareManager()->playAnswerCool();
    } else {
        //播放普通答题正确音效
        GameSoundManager::shareManager()->playAnswerRight();
    }

    isAnswerFinished = true;
}
开发者ID:zhouxj6112,项目名称:HelloWorld-cocos2d-x-2.2.3,代码行数:39,代码来源:QuestionLayer.cpp

示例15: onTouchEnded

void TapRecognizer::onTouchEnded(CCTouch *touch, CCEvent *pEvent)
{
#if VERBOSE_TOUCH_RECOGNIZERS
    CCLOG("linked ? %s", mainLinker->linkedObjectOf(touch) == NULL ? "yes" : "no");
    CCLOG("is in start ? %s", touchStart->objectForKey(touch->getID()) != NULL ? "yes" : "no");
    CCLOG("time ? %s", (TIME - ((CCFloat*)touchStart->objectForKey(touch->getID()))->getValue()) < 2.0 ? "yes" : "no");
    CCLOG("distance ? %s : real : %f", ccpDistance(Scene::touchPosition(touch), touchInitialPosition->at(touch->getID())) < 20 ? "yes" : "no", ccpDistance(Scene::touchPosition(touch), touchInitialPosition->at(touch->getID())));
    CCLOG("initial position : %f, %f, current : %f, %f", touchInitialPosition->at(touch->getID()).x, touchInitialPosition->at(touch->getID()).y, Scene::touchPosition(touch).x, Scene::touchPosition(touch).y);
#endif
    if(mainLinker != NULL
       //&& mainLinker->linkedObjectOf(touch) == NULL //prevent drag + tap from working at the same time
       && touchStart->objectForKey(touch->getID()) != NULL
       && (TIME - ((CCFloat*)touchStart->objectForKey(touch->getID()))->getValue()) < 2.0
       && ccpDistance(Scene::touchPosition(touch), touchInitialPosition.at(touch->getID())) < 50 * RESOLUTION_MULTIPLIER)
    {
        CCDictionary* infos = CCDictionary::create();
        infos->setObject(touch, "Touch");
        CCNotificationCenter::sharedNotificationCenter()->postNotification("TapRecognized", infos);
    }
    touchStart->removeObjectForKey(touch->getID());
    touchInitialPosition.erase(touch->getID());
}
开发者ID:hossainiir,项目名称:FenneX,代码行数:22,代码来源:TapRecognizer.cpp


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