diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index ae644deaf3..0dd0fea3e3 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -285,7 +285,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { memberVarAssignmentName = this->readCachedString(); } - CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className->m_sString); + CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); CCNode * node = ccNodeLoader->loadCCNode(pParent, this); /* Set root node, if not set yet. */ diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index ad655e6a2a..e14056cb06 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -11,8 +11,8 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLOG("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) -#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLOG("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) USING_NS_CC; USING_NS_CC_EXT; diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index c8014ebaba..759861ac08 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -41,19 +41,24 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { this->registerCCNodeLoader("CCParticleSystemQuad", CCParticleSystemQuadLoader::loader()); } -void CCNodeLoaderLibrary::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { +void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { pCCNodeLoader->retain(); this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); } -void CCNodeLoaderLibrary::unregisterCCNodeLoader(std::string pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); +void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) { + pCCNodeLoader->retain(); + this->mCCNodeLoaders.insert(std::pair(pClassName->m_sString, pCCNodeLoader)); +} + +void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); ccNodeLoadersIterator->second->release(); } -CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(std::string pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); +CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index 05352fbcca..17eedec1dc 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -17,9 +17,12 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { ~CCNodeLoaderLibrary(); void registerDefaultCCNodeLoaders(); - void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader); - void unregisterCCNodeLoader(std::string pClassName); - CCNodeLoader * getCCNodeLoader(std::string pClassName); + void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); + void registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader); + void unregisterCCNodeLoader(const char * pClassName); + void unregisterCCNodeLoader(CCString * pClassName); + CCNodeLoader * getCCNodeLoader(const char * pClassName); + CCNodeLoader * getCCNodeLoader(CCString * pClassName); void purge(bool pDelete); public: