From 0488aa6dcbe2cd36301e9bce650066f05935cac8 Mon Sep 17 00:00:00 2001 From: chengstory Date: Mon, 30 Dec 2013 15:26:51 +0800 Subject: [PATCH] fixed #3474 1. Modify CCLOG, Add classname. 2. change ArmatureMovementDispatcher::addAnnimationEventCallBack to ArmatureMovementDispatcher::addAnimationEventCallBack. 3. remove unused do while(0). --- .../editor-support/cocostudio/TriggerMng.cpp | 36 +++++++++---------- cocos/editor-support/cocostudio/TriggerMng.h | 2 +- .../editor-support/cocostudio/TriggerObj.cpp | 14 ++++++-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/cocos/editor-support/cocostudio/TriggerMng.cpp b/cocos/editor-support/cocostudio/TriggerMng.cpp index a81d6abb74..a73666216a 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.cpp +++ b/cocos/editor-support/cocostudio/TriggerMng.cpp @@ -66,24 +66,20 @@ void TriggerMng::destroyInstance() void TriggerMng::parse(const rapidjson::Value &root) { - CCLOG("%s", triggerMngVersion()); - do { - int count = DICTOOL->getArrayCount_json(root, "Triggers"); - for (int i = 0; i < count; ++i) - { - const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers", i); - TriggerObj *obj = TriggerObj::create(); - obj->serialize(subDict); - auto &vInt = obj->getEvents(); - for (const auto& e : vInt) - { - add((unsigned int)e, obj); - } - - _triggerObjs.insert(std::pair(obj->getId(), obj)); - } + int count = DICTOOL->getArrayCount_json(root, "Triggers"); + for (int i = 0; i < count; ++i) + { + const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers", i); + TriggerObj *obj = TriggerObj::create(); + obj->serialize(subDict); + auto &vInt = obj->getEvents(); + for (const auto& e : vInt) + { + add((unsigned int)e, obj); + } - } while (0); + _triggerObjs.insert(std::pair(obj->getId(), obj)); + } } cocos2d::Vector* TriggerMng::get(unsigned int event) const @@ -233,14 +229,14 @@ void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL { amd = new ArmatureMovementDispatcher(); pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(ArmatureMovementDispatcher::animationEvent, amd, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - amd->addAnnimationEventCallBack(pTarget, mecf); + amd->addAnimationEventCallBack(pTarget, mecf); _movementDispatches->insert(std::make_pair(pAr, amd)); } else { amd = iter->second; - amd->addAnnimationEventCallBack(pTarget, mecf); + amd->addAnimationEventCallBack(pTarget, mecf); } } @@ -313,7 +309,7 @@ ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) } } - void ArmatureMovementDispatcher::addAnnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) + void ArmatureMovementDispatcher::addAnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->insert(std::make_pair(pTarget, mecf)); } diff --git a/cocos/editor-support/cocostudio/TriggerMng.h b/cocos/editor-support/cocostudio/TriggerMng.h index a0a9d1dfcc..46f50642e6 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.h +++ b/cocos/editor-support/cocostudio/TriggerMng.h @@ -38,7 +38,7 @@ public: ArmatureMovementDispatcher(void); ~ArmatureMovementDispatcher(void); public: - void addAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); + void addAnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void removeAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); diff --git a/cocos/editor-support/cocostudio/TriggerObj.cpp b/cocos/editor-support/cocostudio/TriggerObj.cpp index 196fd02db2..e37b0c7dc8 100644 --- a/cocos/editor-support/cocostudio/TriggerObj.cpp +++ b/cocos/editor-support/cocostudio/TriggerObj.cpp @@ -167,7 +167,13 @@ void TriggerObj::serialize(const rapidjson::Value &val) continue; } BaseTriggerCondition *con = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - CCAssert(con != nullptr, "class named classname can not implement!"); + if(con == nullptr) + { + CCLOG("class %s can not be implemented!", classname); + CCASSERT(con != nullptr, ""); + } + + CCASSERT(con != nullptr, ""); con->serialize(subDict); con->init(); con->autorelease(); @@ -184,7 +190,11 @@ void TriggerObj::serialize(const rapidjson::Value &val) continue; } BaseTriggerAction *act = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - CCAssert(act != nullptr, "class named classname can not implement!"); + if(act == nullptr) + { + CCLOG("class %s can not be implemented!", classname); + CCASSERT(act != nullptr, ""); + } act->serialize(subDict); act->init(); act->autorelease();