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


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

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


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

示例1: array_Value

static void array_Value(CCArray * aArray, const cocos2d::ValueVector & value)
{
    cocos2d::ValueVector::const_iterator beg = value.begin();
    cocos2d::ValueVector::const_iterator end = value.end();
    for (; beg != end; ++beg)
    {
        const Value & v = *beg;
        if (v.getType() == Value::Type::MAP)
        {
            CCDictionary * dict = new CCDictionary();
            dict->init();
            dictionary_Value(dict, v.asValueMap());
            aArray->addObject(dict);
            dict->release();
        }
        else if (v.getType() == Value::Type::VECTOR)
        {
            CCArray * arr = new CCArray();
            arr->init();
            array_Value(arr, v.asValueVector());
            aArray->addObject(arr);
            arr->release();
        }
        else
        {
            CCString * str = new CCString();
            if (v.getType() == Value::Type::DOUBLE)
                str->initWithFormat("%f", v.asDouble());
            else
                str->initWithFormat("%s", v.asString().c_str());
            aArray->addObject(str);
            str->release();
        }
    }
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:35,代码来源:YHDataManagerImp.cpp

示例2: addSpriteFramesWithFile

void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture)
{
	const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist);
	CCDictionary<std::string, CCObject*> *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(pszPath);

	addSpriteFramesWithDictionary(dict, pobTexture);

	dict->release();
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:9,代码来源:CCSpriteFrameCache.cpp

示例3: removeSpriteFramesFromFile

void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
{
	const char* path = CCFileUtils::fullPathFromRelativePath(plist);
	CCDictionary<std::string, CCObject*>* dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(path);

	removeSpriteFramesFromDictionary((CCDictionary<std::string, CCSpriteFrame*>*)dict);

	dict->release();
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:9,代码来源:CCSpriteFrameCache.cpp

示例4: initWithFile

bool CCParticleSystem::initWithFile(const char *plistFile)
{
    bool bRet = false;
    m_sPlistFile = CCFileUtils::sharedFileUtils()->fullPathForFilename(plistFile);
    CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(m_sPlistFile.c_str());

    CCAssert( dict != NULL, "Particles: file not found");
	bRet = this->initWithDictionary(dict);
	dict->release();

	return bRet;
}
开发者ID:qiuxu,项目名称:Cocos2dWindows,代码行数:12,代码来源:CCParticleSystem.cpp

示例5: CCDictionary

static int tolua_Cocos2dx_CCTableView_registerScriptHandler(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"CCTableView",0,&tolua_err) ||
        !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
        !tolua_isnumber(tolua_S, 3, 0, &tolua_err)               ||
        !tolua_isnoobj(tolua_S,4,&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 'registerScriptHandler'", NULL);
#endif
        if (NULL == self->getDelegate())
        {
            LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate();
            if (NULL == delegate)
                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(delegate, KEY_TABLEVIEW_DELEGATE);
            self->setDelegate(delegate);
            delegate->release();
        }
        
        LUA_FUNCTION nFunID = (  toluafix_ref_function(tolua_S,2,0));
        int scriptHandlerType = ((int)  tolua_tonumber(tolua_S,3,0));
        self->registerScriptHandler(nFunID,scriptHandlerType);
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
    return 0;
#endif
}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:51,代码来源:lua_cocos2dx_extensions_manual.cpp

示例6: addSpriteFrameFromFile

	void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *_plistPath, const char *_imagePath)
	{

		std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(_plistPath);
		CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(path.c_str());


		CCTexture2D *pobTexture = CCTextureCache::sharedTextureCache()->addImage(_imagePath);

		addSpriteFrameFromDict(dict, pobTexture, _imagePath);

		dict->release();

	}
开发者ID:Jinchenyuan,项目名称:shjs,代码行数:14,代码来源:CSSpriteFrameCacheHelper.cpp

示例7: startElement

void startElement(void *ctx, const XML_Char *name, const XML_Char **atts)
{
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		CCDictionary<std::string, CCObject*> *pNewDict = new CCDictionary<std::string, CCObject*>();
		if(! m_pRootDict)
		{
			m_pRootDict = pNewDict;
			pNewDict->autorelease();
		}
		else
		{
			CCAssert(m_pCurDict && !m_sCurKey.empty(), "");
			m_pCurDict->setObject(pNewDict, m_sCurKey);
			pNewDict->release();
			m_sCurKey.clear();
		}
		m_pCurDict = pNewDict;
		m_tDictStack.push(m_pCurDict);
		m_tState = SAX_DICT;
	}
	else if(sName == "key")
	{
		m_tState = SAX_KEY;
	}
	else if(sName == "integer")
	{
		m_tState = SAX_INT;
	}
	else if(sName == "real")
	{
		m_tState = SAX_REAL;
	}
	else if(sName == "string")
	{
		m_tState = SAX_STRING;
	}
	else
	{
        if (sName == "array")
        {
            m_bInArray = true;
            m_pArray = new CCMutableArray<CCObject*>();
        }
		m_tState = SAX_NONE;
	}	
}
开发者ID:flyingpacer,项目名称:cocos2d-x-samples,代码行数:48,代码来源:CCFileUtils_airplay.cpp

示例8: _LoadTextureAsync

//-------------------------------------------------------------------------
// 加载贴图
void FKAnimateExRes::_LoadTextureAsync( const char* szResName )
{
	string strPathName = CCFileUtils::sharedFileUtils()->fullPathForFilename( szResName );
	if( !m_SaxParser.init("UTF-8") )
		return;
	m_SaxParser.setDelegator( &m_SaxDelegator );
	if( !m_SaxParser.parse( strPathName.c_str() ) )
		return;

	vector<string>	vecPlists = m_SaxDelegator.m_vecPlists;
	for( unsigned int i = 0; i < vecPlists.size(); ++i )
	{
		string strFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(
			vecPlists[i].c_str(), strPathName.c_str() );
		CCDictionary *pDict = CCDictionary::createWithContentsOfFileThreadSafe( strFullPath.c_str() );
		if( pDict == NULL )
			continue;

		string strTexturePath("");
		CCDictionary* pMetadataDict = (CCDictionary*)pDict->objectForKey("metadata");
		if( pMetadataDict )
			strTexturePath = pMetadataDict->valueForKey("textureFileName")->getCString();

		if( !strTexturePath.empty() )
		{
			strTexturePath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile( 
				strTexturePath.c_str(), strPathName.c_str() );
		}
		else
		{
			strTexturePath = vecPlists[i].c_str();

			size_t unStartPos = strTexturePath.find_last_of(".");
			strTexturePath = strTexturePath.erase( unStartPos );

			strTexturePath = strTexturePath.append(".png");
		}

		pDict->release();

		m_mapTextureLoadInfo[strTexturePath] = false;
		CCTextureCache::sharedTextureCache()->addImageAsync(
			strTexturePath.c_str(),this, callfuncO_selector(FKAnimateExRes::_OnImageLoadOver) );
	}
}
开发者ID:duzhi5368,项目名称:FKCocos2dxWrapper_2.x,代码行数:47,代码来源:FKAnimateExRes.cpp

示例9: plist_startElement

void plist_startElement(void *ctx, const xmlChar *name, const xmlChar **atts)
{
	CCDictMaker *pMaker = (CCDictMaker*)(ctx);
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		CCDictionary<std::string, CCObject*> *pNewDict = new CCDictionary<std::string, CCObject*>();
		if(! pMaker->m_pRootDict)
		{
			pMaker->m_pRootDict = pNewDict;
			pNewDict->autorelease();
		}
		else
		{
			CCAssert(pMaker->m_pCurDict && !pMaker->m_sCurKey.empty(), "");
			pMaker->m_pCurDict->setObject(pNewDict, pMaker->m_sCurKey);
			pNewDict->release();
			pMaker->m_sCurKey.clear();
		}
		pMaker->m_pCurDict = pNewDict;
		pMaker->m_tDictStack.push(pMaker->m_pCurDict);
		pMaker->m_tState = SAX_DICT;
	}
	else if(sName == "key")
	{
		pMaker->m_tState = SAX_KEY;
	}
	else if(sName == "integer")
	{
		pMaker->m_tState = SAX_INT;
	}
	else if(sName == "real")
	{
		pMaker->m_tState = SAX_REAL;
	}
	else if(sName == "string")
	{
		pMaker->m_tState = SAX_STRING;
	}
	else
	{
		pMaker->m_tState = SAX_NONE;
	}
}
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:44,代码来源:CCFileUtils_android.cpp

示例10: addSingle

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

示例11: if

JNIEXPORT void JNICALL Java_cn_sharesdk_ShareSDKUtils_onJavaCallback
  (JNIEnv * env, jclass thiz, jstring resp) {
	CCJSONConverter* json = CCJSONConverter::sharedConverter();
	const char* ccResp = env->GetStringUTFChars(resp, JNI_FALSE);
	CCLog("ccResp = %s", ccResp);
	CCDictionary* dic = json->dictionaryFrom(ccResp);
	env->ReleaseStringUTFChars(resp, ccResp);
	CCNumber* status = (CCNumber*) dic->objectForKey("status"); // Success = 1, Fail = 2, Cancel = 3 
	CCNumber* action = (CCNumber*) dic->objectForKey("action"); //  1 = ACTION_AUTHORIZING,  8 = ACTION_USER_INFOR,9 = ACTION_SHARE
	CCNumber* platform = (CCNumber*) dic->objectForKey("platform");
	CCDictionary* res = (CCDictionary*) dic->objectForKey("res");
	// TODO add codes here
	if(1 == status->getIntValue()){
		callBackComplete(action->getIntValue(), platform->getIntValue(), res);
	}else if(2 == status->getIntValue()){
		callBackError(action->getIntValue(), platform->getIntValue(), res);
	}else{
		callBackCancel(action->getIntValue(), platform->getIntValue(), res);
	}
	
	dic->release();
}
开发者ID:00000110,项目名称:Four,代码行数:22,代码来源:ShareSDKUtils.cpp

示例12: initWithFileFullPath

bool CCParticleSystem::initWithFileFullPath(const char *plistFile)
{
    bool bRet = false;
    CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(plistFile);
	
    CCAssert( dict != NULL, "Particles: file not found");
    
    // XXX compute path from a path, should define a function somewhere to do it
    string listFilePath = plistFile;
    if (listFilePath.find('/') != string::npos)
    {
        listFilePath = listFilePath.substr(0, listFilePath.rfind('/') + 1);
        bRet = this->initWithDictionary(dict, listFilePath.c_str());
    }
    else
    {
        bRet = this->initWithDictionary(dict, "");
    }
    
    dict->release();
	
    return bRet;
}
开发者ID:devmario,项目名称:cocos2d-x,代码行数:23,代码来源:CCParticleSystem.cpp

示例13: dictionary_Value

static void dictionary_Value(CCDictionary * aDict, const cocos2d::ValueMap & value)
{
    cocos2d::ValueMap::const_iterator beg = value.begin();
    cocos2d::ValueMap::const_iterator end = value.end();
    for (; beg != end; ++beg)
    {
        const std::string & key = (*beg).first;
        const cocos2d::Value & v = (*beg).second;
        if (v.getType() == Value::Type::MAP)
        {
            CCDictionary * d = new CCDictionary();
            d->init();
            dictionary_Value(d, v.asValueMap());
            aDict->setObject(d, key);
            d->release();
        }
        else if (v.getType() == Value::Type::VECTOR)
        {
            CCArray * a = new CCArray();
            a->init();
            array_Value(a, v.asValueVector());
            aDict->setObject(a, key);
            a->release();
        }
        else
        {
            CCString * str = new CCString();
            if (v.getType() == Value::Type::DOUBLE)
                str->initWithFormat("%f", v.asDouble());
            else
                str->initWithFormat("%s", v.asString().c_str());
            aDict->setObject(str, key);
            str->release();
        }
    }
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:36,代码来源:YHDataManagerImp.cpp

示例14: startElement

    void startElement(void *ctx, const char *name, const char **atts)
    {
        CC_UNUSED_PARAM(ctx);
        CC_UNUSED_PARAM(atts);
        std::string sName((char*)name);
        if( sName == "dict" )
        {
            m_pCurDict = new CCDictionary();
            if (m_eResultType == SAX_RESULT_DICT && ! m_pRootDict)
            {
				// Because it will call m_pCurDict->release() later, so retain here.
                m_pRootDict = m_pCurDict;
				m_pRootDict->retain();
            }
            m_tState = SAX_DICT;

            CCSAXState preState = SAX_NONE;
            if (! m_tStateStack.empty())
            {
                preState = m_tStateStack.top();
            }

            if (SAX_ARRAY == preState)
            {
                // add the dictionary into the array
                m_pArray->addObject(m_pCurDict);
            }
            else if (SAX_DICT == preState)
            {
                // add the dictionary into the pre dictionary
                CCAssert(! m_tDictStack.empty(), "The state is wrong!");
                CCDictionary* pPreDict = m_tDictStack.top();
                pPreDict->setObject(m_pCurDict, m_sCurKey);
            }

			m_pCurDict->release();

            // record the dict state
            m_tStateStack.push(m_tState);
            m_tDictStack.push(m_pCurDict);
        }
        else if(sName == "key")
        {
            m_tState = SAX_KEY;
        }
        else if(sName == "integer")
        {
            m_tState = SAX_INT;
        }
        else if(sName == "real")
        {
            m_tState = SAX_REAL;
        }
        else if(sName == "string")
        {
            m_tState = SAX_STRING;
        }
        else if (sName == "array")
        {
            m_tState = SAX_ARRAY;
            m_pArray = new CCArray();
            if (m_eResultType == SAX_RESULT_ARRAY && m_pRootArray == NULL)
            {
                m_pRootArray = m_pArray;
                m_pRootArray->retain();
            }
            CCSAXState preState = SAX_NONE;
            if (! m_tStateStack.empty())
            {
                preState = m_tStateStack.top();
            }

            //CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
            if (preState == SAX_DICT)
            {
                m_pCurDict->setObject(m_pArray, m_sCurKey);
            }
            else if (preState == SAX_ARRAY)
            {
                CCAssert(! m_tArrayStack.empty(), "The state is worng!");
                CCArray* pPreArray = m_tArrayStack.top();
                pPreArray->addObject(m_pArray);
            }
            m_pArray->release();
            // record the array state
            m_tStateStack.push(m_tState);
            m_tArrayStack.push(m_pArray);
        }
        else
        {
            m_tState = SAX_NONE;
        }
    }
开发者ID:QiMa,项目名称:Cocos2dWindows,代码行数:93,代码来源:CCFileUtils.cpp

示例15: loadPlistAsync

void AsyncLoadPlist::loadPlistAsync(const char *pszPlist, cocos2d::CCObject *target, SEL_CallFuncO selector)
{
    CCAssert(pszPlist, "plist filename should not be NULL");
    
    // 读取plist数据,获得图片路径
    const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(pszPlist).c_str();
    CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath);
    
    std::string texturePath("");
    
    CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata");
    if (metadataDict)
    {
        // try to read  texture file name from meta data
        texturePath = metadataDict->valueForKey("textureFileName")->getCString();
    }
    
	// CCDictionary::createWithContentsOfFileThreadSafe 需要释放dict
	dict->release();

    if (! texturePath.empty())
    {
        // build texture path relative to plist file
        texturePath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(texturePath.c_str(), pszPath);
    }
    else
    {
        CCAssert(0, "在plist文件中没有找到图片文件");
        return;
    }
    
    // 从texturePath中取文件名 如/../../filename.png 则filename.png
    std::string textureFileName = texturePath.substr(texturePath.rfind('/') + 1);
    
    // 从TextureCache中找到纹理就直接返回
    CCTexture2D *texture = CCTextureCache::sharedTextureCache()->textureForKey(textureFileName.c_str());
    if (texture != NULL)
    {
        if (target && selector)
        {
            (target->*selector)(CCString::create(pszPlist));
        }
        
        return;
    }
    
    // lazy init
    if (s_pSem == NULL)
    {             
#if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE
        s_pSem = sem_open(CC_ASYNC_TEXTURE_CACHE_SEMAPHORE, O_CREAT, 0644, 0);
        if( s_pSem == SEM_FAILED )
        {
            CCLOG( "CCTextureCache async thread semaphore init error: %s\n", strerror( errno ) );
            s_pSem = NULL;
            return;
        }
#else
        int semInitRet = sem_init(&s_sem, 0, 0);
        if( semInitRet < 0 )
        {
            CCLOG( "CCTextureCache async thread semaphore init error: %s\n", strerror( errno ) );
            return;
        }
        s_pSem = &s_sem;
#endif
        s_pLoadStructQueue = new std::queue<LoadStruct*>();
        s_pImageQueue = new std::queue<ImageInfo*>();        
        
        pthread_mutex_init(&s_loadStructQueueMutex, NULL);
        pthread_mutex_init(&s_ImageInfoMutex, NULL);
        pthread_create(&s_loadingThread, NULL, loadImage, NULL);
        
        need_quit = false;
    }
    
    if (0 == s_nAsyncRefCount)
    {
        CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(AsyncLoadPlist::loadPlistAsyncCallBack), this, 0, false);
    }
    
    ++s_nAsyncRefCount;
    
    if (target)
    {
        target->retain();
    }
    
    // generate async struct
    LoadStruct *data = new LoadStruct();
    data->texturePath = texturePath.c_str();
    data->plistFileName = pszPlist;
    data->target = target;
    data->selector = selector;
    
    // add async struct into queue
    pthread_mutex_lock(&s_loadStructQueueMutex);
    s_pLoadStructQueue->push(data);
    pthread_mutex_unlock(&s_loadStructQueueMutex);
    
//.........这里部分代码省略.........
开发者ID:echenonline,项目名称:Blackcat,代码行数:101,代码来源:AsyncLoadPlist.cpp


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