issue #2790: Uses Map<K, V> instead of Dictionary in CCBAnimationManager.

This commit is contained in:
James Chen 2013-12-09 18:17:04 +08:00
parent ad5daeb962
commit 64fd2386a9
2 changed files with 12 additions and 11 deletions

View File

@ -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<int>(selectorTarget);
callbackName << ":" + selectorName;
auto callback = _keyframeCallFuncs.at(callbackName.str());
if (nullptr != callback)
{
CallFunc *callbackClone = (static_cast<CallFunc*>(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()

View File

@ -146,7 +146,7 @@ private:
cocos2d::Vector<cocos2d::Node*> _documentCallbackNodes;
cocos2d::ValueVector _documentCallbackControlEvents;
cocos2d::ValueVector _keyframeCallbacks;
cocos2d::Dictionary *_keyframeCallFuncs;
cocos2d::Map<std::string, cocos2d::CallFunc*> _keyframeCallFuncs;
std::string _documentControllerName;
std::string _lastCompletedSequenceName;