diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index b2091936f4..bcdd041e01 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -33,9 +33,6 @@ CCBAnimationManager::CCBAnimationManager() bool CCBAnimationManager::init() { - _keyframeCallFuncs = new Dictionary(); - _keyframeCallFuncs->init(); - _target = NULL; _animationCompleteCallbackFunc = NULL; @@ -68,7 +65,6 @@ CCBAnimationManager::~CCBAnimationManager() } } - CC_SAFE_RELEASE(_keyframeCallFuncs); CC_SAFE_RELEASE(_target); } @@ -640,13 +636,17 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann CCBReader::TargetType selectorTarget = (CCBReader::TargetType)keyVal[1].asInt(); if(_jsControlled) { - String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str()); - Object* callback = _keyframeCallFuncs->objectForKey(callbackName->getCString()); + std::stringstream callbackName; + callbackName << static_cast(selectorTarget); + callbackName << ":" + selectorName; + + auto callback = _keyframeCallFuncs.at(callbackName.str()); if (nullptr != callback) { - CallFunc *callbackClone = (static_cast(callback))->clone(); + CallFunc* callbackClone = callback->clone(); - if(callbackClone != NULL) { + if (callbackClone != NULL) + { actions.pushBack(callbackClone); } } @@ -908,8 +908,9 @@ void CCBAnimationManager::setAnimationCompletedCallback(Object *target, SEL_Call _animationCompleteCallbackFunc = callbackFunc; } -void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) { - _keyframeCallFuncs->setObject((Object*)callFunc, callbackNamed); +void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) +{ + _keyframeCallFuncs.insert(callbackNamed, callFunc); } void CCBAnimationManager::sequenceCompleted() diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h index a5ed09042f..14328af61d 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h @@ -146,7 +146,7 @@ private: cocos2d::Vector _documentCallbackNodes; cocos2d::ValueVector _documentCallbackControlEvents; cocos2d::ValueVector _keyframeCallbacks; - cocos2d::Dictionary *_keyframeCallFuncs; + cocos2d::Map _keyframeCallFuncs; std::string _documentControllerName; std::string _lastCompletedSequenceName;