mirror of https://github.com/axmolengine/axmol.git
commit
c7fd67ee29
|
@ -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<unsigned int, TriggerObj*>(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<unsigned int, TriggerObj*>(obj->getId(), obj));
|
||||
}
|
||||
}
|
||||
|
||||
cocos2d::Vector<TriggerObj*>* 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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -167,7 +167,13 @@ void TriggerObj::serialize(const rapidjson::Value &val)
|
|||
continue;
|
||||
}
|
||||
BaseTriggerCondition *con = dynamic_cast<BaseTriggerCondition*>(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<BaseTriggerAction*>(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();
|
||||
|
|
Loading…
Reference in New Issue