void ActionObject::initWithDictionary(JsonDictionary *dic,Object* root) { setName(DICTOOL->getStringValue_json(dic, "name")); setLoop(DICTOOL->getBooleanValue_json(dic, "loop")); setUnitTime(DICTOOL->getFloatValue_json(dic, "unittime")); int actionNodeCount = DICTOOL->getArrayCount_json(dic, "actionnodelist"); for (int i=0; i<actionNodeCount; i++) { ActionNode* actionNode = new ActionNode(); actionNode->autorelease(); JsonDictionary* actionNodeDic = DICTOOL->getDictionaryFromArray_json(dic, "actionnodelist", i); actionNode->initWithDictionary(actionNodeDic,root); actionNode->setUnitTime(getUnitTime()); _actionNodeList->addObject(actionNode); CC_SAFE_DELETE(actionNodeDic); } }
void ActionObject::initWithBinary(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Ref *root) { stExpCocoNode *stChildNode = cocoNode->GetChildArray(cocoLoader); stExpCocoNode *actionNodeList = nullptr; int count = cocoNode->GetChildNum(); for (int i = 0; i < count; ++i) { std::string key = stChildNode[i].GetName(cocoLoader); std::string value = stChildNode[i].GetValue(cocoLoader); if (key == "name") { setName(value.c_str()); }else if (key == "loop"){ setLoop(valueToBool(value)); }else if(key == "unittime"){ setUnitTime(valueToFloat(value)); }else if (key == "actionnodelist"){ actionNodeList = &stChildNode[i]; } } if(nullptr != actionNodeList) { int actionNodeCount = actionNodeList->GetChildNum(); stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray(cocoLoader); int maxLength = 0; for (int i=0; i<actionNodeCount; i++) { ActionNode* actionNode = new ActionNode(); actionNode->autorelease(); actionNode->initWithBinary(cocoLoader, &actionNodeArray[i] , root); actionNode->setUnitTime(getUnitTime()); _actionNodeList.pushBack(actionNode); int length = actionNode->getLastFrameIndex() - actionNode->getFirstFrameIndex(); if(length > maxLength) maxLength = length; } _fTotalTime = maxLength* _fUnitTime; } }
void ActionObject::initWithDictionary(const rapidjson::Value& dic, Ref* root) { setName(DICTOOL->getStringValue_json(dic, "name")); setLoop(DICTOOL->getBooleanValue_json(dic, "loop")); setUnitTime(DICTOOL->getFloatValue_json(dic, "unittime")); int actionNodeCount = DICTOOL->getArrayCount_json(dic, "actionnodelist"); int maxLength = 0; for (int i=0; i<actionNodeCount; i++) { ActionNode* actionNode = new ActionNode(); actionNode->autorelease(); const rapidjson::Value& actionNodeDic = DICTOOL->getDictionaryFromArray_json(dic, "actionnodelist", i); actionNode->initWithDictionary(actionNodeDic,root); actionNode->setUnitTime(getUnitTime()); _actionNodeList.pushBack(actionNode); int length = actionNode->getLastFrameIndex() - actionNode->getFirstFrameIndex(); if(length > maxLength) maxLength = length; } _fTotalTime = maxLength*_fUnitTime; }