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


C++ CCDictionary类代码示例

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


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

示例1: getItemBalance

    int CCStoreInventory::getItemBalance(char const *itemId, CCSoomlaError **soomlaError) {
        CCStoreUtils::logDebug(TAG,
                CCString::createWithFormat("SOOMLA/COCOS2DX Calling getItemBalance with: %s", itemId)->getCString());
        CCDictionary *params = CCDictionary::create();
        params->setObject(CCString::create("CCStoreInventory::getItemBalance"), "method");
        params->setObject(CCString::create(itemId), "itemId");
        CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError);

        if (retParams == NULL) {
        	return 0;
        }

		CCInteger *retValue = (CCInteger *) retParams->objectForKey("return");
		if (retValue) {
			return retValue->getValue();
		} else {
			return 0;
		}
    }
开发者ID:ciw604878870,项目名称:cocos2dx-store,代码行数:19,代码来源:CCStoreInventory.cpp

示例2: getGoodCurrentUpgrade

    std::string CCStoreInventory::getGoodCurrentUpgrade(char const *goodItemId, CCSoomlaError **soomlaError) {
        CCStoreUtils::logDebug(TAG,
                CCString::createWithFormat("SOOMLA/COCOS2DX Calling getGoodCurrentUpgrade with: %s", goodItemId)->getCString());
        CCDictionary *params = CCDictionary::create();
        params->setObject(CCString::create("CCStoreInventory::getGoodCurrentUpgrade"), "method");
        params->setObject(CCString::create(goodItemId), "goodItemId");
        CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError);

        if (retParams == NULL) {
        	return "";
        }

		CCString *retValue = (CCString *) retParams->objectForKey("return");
		if (retValue) {
			return retValue->getCString();
		} else {
			return "";
		}
    }
开发者ID:ciw604878870,项目名称:cocos2dx-store,代码行数:19,代码来源:CCStoreInventory.cpp

示例3: CCLOG

void CCFileUtils::loadFilenameLookupDictionaryFromFile(const char* filename)
{
    std::string fullPath = this->fullPathForFilename(filename);
    if (fullPath.length() > 0)
    {
        CCDictionary* pDict = CCDictionary::createWithContentsOfFile(fullPath.c_str());
        if (pDict)
        {
            CCDictionary* pMetadata = (CCDictionary*)pDict->objectForKey("metadata");
            int version = ((CCString*)pMetadata->objectForKey("version"))->intValue();
            if (version != 1)
            {
                CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename);
                return;
            }
            setFilenameLookupDictionary((CCDictionary*)pDict->objectForKey("filenames"));
        }
    }
}
开发者ID:HotWordland,项目名称:cocos2d-x,代码行数:19,代码来源:CCFileUtils.cpp

示例4: _dict

bool InviteRewardCommand::handleRecieve(cocos2d::CCDictionary *dict){
    if(dict->valueForKey("cmd")->compare(INVITE_REWARD) != 0) {
        return false;
    }
    
    CCDictionary *params = _dict(dict->objectForKey("params"));
    
    if (!params) {
        return false;
    }
    
    if (params->objectForKey("errorCode")) {
        callFail(NetResult::createWithFail(params));
    } else {
        callSuccess(NetResult::createWithSuccess(params));
    }
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_REFREASH_TOOL_DATA);
    return true;
}
开发者ID:ourgames,项目名称:dc208,代码行数:19,代码来源:InviteForGiftCommand.cpp

示例5: _dict

bool LotteryActCommand::handleRecieve1(cocos2d::CCDictionary *dict)
{
    CCDictionary* resourceDic = _dict(dict->objectForKey("resource"));
    
    if (resourceDic->objectForKey("chip"))
    {
        GlobalData::shared()->resourceInfo.lChip = resourceDic->valueForKey("chip")->intValue();
    }
    if (resourceDic->objectForKey("gold"))
    {
        GlobalData::shared()->playerInfo.gold = resourceDic->valueForKey("gold")->intValue();
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_CITY_RESOURCES_UPDATE);
    }
    
    LotteryController::shared()->lotteryActCmdBack(dict);
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(LOTTERYACTVIEWCMD, NetResult::createWithSuccess(dict));
    
    return true;
}
开发者ID:ourgames,项目名称:dc208,代码行数:19,代码来源:LotteryActCommand.cpp

示例6: resetGame

void GameScene::resetGame( )
{
    CCArray * pArray  = (CCArray*)m_pEnemyInfos->objectAtIndex(global::getGameLevel());
    CCDictionary * pDic =  (CCDictionary*)pArray->objectAtIndex(0);
    int iBulletNum = pDic->valueForKey("BulletNumber")->intValue();
    
    
    this->createBullets(iBulletNum);
    this->attachBullet();
    
   
    
    //镜头移动
    CCFiniteTimeAction * action1 = CCMoveTo::create(1.5f, ccp(2*-480.0f, 0.0f));
    CCDelayTime *action3 = CCDelayTime::create(1.0f);
    CCFiniteTimeAction *action4 = CCMoveTo::create(1.5f, CCPointZero);
    runAction(CCSequence::create(action1,action3, action4, NULL));

}
开发者ID:momirror,项目名称:MyAngerBird-,代码行数:19,代码来源:GameScene.cpp

示例7: getTotalBytes

int CCPreLoad::getTotalBytes()
{
	if(!m_dict)
		return -1;
	int ret = -1;
	int total = 0;
	CCArray* arr = m_dict->allKeys();
	if(!arr)
		return 0;
	do
	{
		unsigned int i;
		for(i=0; i<arr->count(); ++i)
		{
			CCString* p = dynamic_cast<CCString*>(arr->objectAtIndex(i));
			if(!p)
				break;
			
			CCDictionary* pdic = dynamic_cast<CCDictionary*>(m_dict->objectForKey(p->getCString()));
			if(!pdic)
				break;

			CCString* p1 = dynamic_cast<CCString*>(pdic->objectForKey("size"));
			if(!p1)
				break;

			total += p1->intValue();
		}
		
		if(i!=arr->count())
		{
			break;
		}

		ret = total;
		m_tmpTotalBytes = total;
	}while(0);

	delete arr;

	return ret;
}
开发者ID:marszaya,项目名称:huihe,代码行数:42,代码来源:CPreLoad.cpp

示例8: CC_SAFE_RETAIN

CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &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 CCArray();
    mOwnerCallbackNodes = new CCArray();
    
    CCDictionary* animationManagers = CCDictionary::create();
    CCNode *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 CCArray();
        mAnimationManagersForNodes = new CCArray();
    }
    
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(animationManagers, pElement)
    {
        CCNode* pNode = (CCNode*)pElement->getIntKey();
        CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode);
        pNode->setUserObject(manager);

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

示例9: GetJsonFromCCObject

json_t* NDKHelper::GetJsonFromCCObject(CCObject* obj)
{
    if (dynamic_cast<CCDictionary*>(obj))
    {
        CCDictionary *mainDict = (CCDictionary*)obj;
        CCArray *allKeys = mainDict->allKeys();
        json_t* jsonDict = json_object();
        
        if(allKeys == NULL ) return jsonDict;
        for (unsigned int i = 0; i < allKeys->count(); i++)
        {
            const char *key = ((CCString*)allKeys->objectAtIndex(i))->getCString();
            json_object_set_new(jsonDict,
                                key,
                                NDKHelper::GetJsonFromCCObject(mainDict->objectForKey(key)));
        }
        
        return jsonDict;
    }
    else if (dynamic_cast<CCArray*>(obj))
    {
        CCArray* mainArray = (CCArray*)obj;
        json_t* jsonArray = json_array();
        
        for (unsigned int i = 0; i < mainArray->count(); i++)
        {
            json_array_append_new(jsonArray,
                                  NDKHelper::GetJsonFromCCObject(mainArray->objectAtIndex(i)));
        }
        
        return jsonArray;
    }
    else if (dynamic_cast<CCString*>(obj))
    {
        CCString* mainString = (CCString*)obj;
        json_t* jsonString = json_string(mainString->getCString());
        
        return jsonString;
    }
    
    return NULL;
}
开发者ID:AllenCoder,项目名称:EasyNDK-for-cocos2dx,代码行数:42,代码来源:NDKHelper.cpp

示例10: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    _tileMap = CCTMXTiledMap::create("map.tmx");
    _background = _tileMap->layerNamed("Background");

    this->addChild(_tileMap,-1);
    
    CCTMXObjectGroup *objects = _tileMap->objectGroupNamed("object");
    CCDictionary *c = objects->objectNamed("SpawnPoint");
   
    
    CCTMXObjectGroup *group = _tileMap->objectGroupNamed("object");
    CCDictionary *spwnPoint = group->objectNamed("SpawnPoint");
    int px = spwnPoint->valueForKey("x")->floatValue();
    int py = spwnPoint->valueForKey("y")->floatValue();
    
    
    
    _player = ShunSprite::create();
    _player->setPosition(ccp(px,py));
    _tileMap->addChild(_player);
    this->setViewPointCenter(_player->getPosition());
//    CCTMXLayer *wall = _tileMap->layerNamed("wall");
//    wall->setVisible(false);
    _meta = _tileMap->layerNamed("meta");
    _meta->setVisible(false);
    

    
    int gid = _background->tileGIDAt(ccp(10,10));
    CCLog("backGID:%d",gid);
    
    this->registerWithTouchDispatcher();
    return true;
}
开发者ID:wengxianxun,项目名称:xiyouji,代码行数:43,代码来源:HelloWorldScene.cpp

示例11: tolua_Cocos2dx_CCTableView_create01

static int tolua_Cocos2dx_CCTableView_create01(lua_State* tolua_S)
{
    tolua_Error tolua_err;
    if (
        !tolua_isusertable(tolua_S,1,"CCTableView",0,&tolua_err) ||
        !tolua_isusertype(tolua_S, 2, "CCSize", 0, &tolua_err)   ||
        !tolua_isusertype(tolua_S,3,"CCNode",0,&tolua_err)       ||
        !tolua_isnoobj(tolua_S,4,&tolua_err)
        )
        goto tolua_lerror;
    else
    {
        
        LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource();
        if (NULL == dataSource)
            return 0;
        
        CCSize size = *((CCSize*)  tolua_tousertype(tolua_S,2,0));
        CCNode* node = static_cast<CCNode*>(tolua_tousertype(tolua_S, 3, 0));
        CCTableView* tolua_ret = CCTableView::create(dataSource,size,node);
        if (NULL == tolua_ret)
            return 0;
        
        tolua_ret->reloadData();
        
        CCDictionary* userDict = new CCDictionary();
        userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);
        tolua_ret->setUserObject(userDict);
        userDict->release();
        
        dataSource->release();
        
        
        int  nID = (int)tolua_ret->m_uID;
        int* pLuaID =  &tolua_ret->m_nLuaID;
        toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCTableView");
        return 1;
    }
    return 0;
tolua_lerror:
    return tolua_Cocos2dx_CCTableView_create00(tolua_S);
}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:42,代码来源:lua_cocos2dx_extensions_manual.cpp

示例12: ccpAdd

bool RPGMapSceneLayer::doMoving(cocos2d::CCPoint targetPoint)
{
    //这里的逻辑跟RPGMapNPCRoleSprite::autoMove类似
    
    CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
    RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer);
    CCTMXObjectGroup *obstaclesObjects = bgMap->objectGroupNamed("obstacles");
    
    targetPoint = ccpAdd(player->getPosition(), targetPoint);
    
    //地图上的障碍物
    for (int i = 0; i < obstaclesObjects->getObjects()->count(); i++)
    {
        CCDictionary *obstaclesObject = (CCDictionary*)obstaclesObjects->getObjects()->objectAtIndex(i);
        const CCString *x = obstaclesObject->valueForKey("x");
        const CCString *y = obstaclesObject->valueForKey("y");
        const CCString *width = obstaclesObject->valueForKey("width");
        const CCString *height = obstaclesObject->valueForKey("height");
        
        CCRect obstaclesRect = CCRectMake(stringToNumber<float>(x->getCString()), stringToNumber<float>(y->getCString()), stringToNumber<float>(width->getCString()), stringToNumber<float>(height->getCString()));
        
        if(obstaclesRect.containsPoint(targetPoint))
            return false;
    }
    
    //NPC或Player
    for (int i = 0; i < bgMap->getChildren()->count(); i++)
    {
        CCObject *item = bgMap->getChildren()->objectAtIndex(i);
        if(dynamic_cast<RPGMapRoleSprite*>(item) != NULL)
        {
            //如果为非player的对象才会执行里面的判断
            if(item != player)
            {
                if(((RPGMapRoleSprite*)item)->boundingBox().containsPoint(targetPoint))
                    return false;
            }
        }
    }
    
    return true;
}
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:42,代码来源:RPGMapSceneLayer.cpp

示例13: CCDictionary

int CCPreLoad::addSingle(const char* pic, int type, int size)
{
	int ret = -1;
	CCDictionary* dic = new CCDictionary();
	CCString* str = new CCString();
	CCString* str1 = new CCString();
	do{
		str->initWithFormat("%d", type);
		str1->initWithFormat("%d", size);

		dic->setObject(str1, "size");
		dic->setObject(str, "type");
		m_dict->setObject(dic, pic);
		ret = 0;
	}while(0);
	dic->release();
	str->release();
	str1->release();
	return ret;
}
开发者ID:marszaya,项目名称:huihe,代码行数:20,代码来源:CPreLoad.cpp

示例14: isVirtualGoodEquipped

    bool CCStoreInventory::isVirtualGoodEquipped(char const *itemId, CCSoomlaError **soomlaError) {
        CCStoreUtils::logDebug(TAG,
                CCString::createWithFormat("SOOMLA/COCOS2DX Calling isVirtualGoodEquipped with: %s", itemId)->getCString());

        CCDictionary *params = CCDictionary::create();
        params->setObject(CCString::create("CCStoreInventory::isVirtualGoodEquipped"), "method");
        params->setObject(CCString::create(itemId), "itemId");
        CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError);

        if (retParams == NULL) {
        	return false;
        }

		CCBool *retValue = (CCBool *) retParams->objectForKey("return");
		if (retValue) {
			return retValue->getValue();
		} else {
			return false;
		}
    }
开发者ID:ciw604878870,项目名称:cocos2dx-store,代码行数:20,代码来源:CCStoreInventory.cpp

示例15: 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


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