Ejemplo n.º 1
0
 void ActionManagerEx::initWithBinary(const char* file,
                                      cocos2d::Ref *root,
                                      CocoLoader* cocoLoader,
                                      stExpCocoNode*	pCocoNode)
 {
     std::string path = file;
     ssize_t pos = path.find_last_of("/");
     std::string fileName = path.substr(pos+1,path.length());
     cocos2d::Vector<ActionObject*> actionList;
     
     stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
     stExpCocoNode *actionNode = nullptr;
     for (int i=0; i < pCocoNode->GetChildNum(); ++i) {
         std::string key = stChildArray[i].GetName(cocoLoader);
         if (key == "actionlist") {
             actionNode = &stChildArray[i];
             break;
         }
     }
     if (nullptr != actionNode)
     {
         int actionCount = actionNode->GetChildNum();
         for (int i = 0; i < actionCount; ++i) {
             ActionObject* action = new (std::nothrow) ActionObject();
             action->autorelease();
             
             action->initWithBinary(cocoLoader, &actionNode->GetChildArray(cocoLoader)[i], root);
             
             actionList.pushBack(action);
         }
     }
     _actionDic[fileName] = actionList;
     
 }
Ejemplo n.º 2
0
void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root)
{
	std::string path = jsonName;
	ssize_t pos = path.find_last_of("/");
	std::string fileName = path.substr(pos+1,path.length());
	cocos2d::Vector<ActionObject*> actionList;
	int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
	for (int i=0; i<actionCount; i++) {
		ActionObject* action = new (std::nothrow) ActionObject();
		action->autorelease();
		const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
		action->initWithDictionary(actionDic,root);
		actionList.pushBack(action);
	}
	_actionDic[fileName] = actionList;
}
Ejemplo n.º 3
0
void ActionManager::initWithDictionary(const char* jsonName,cs::CSJsonDictionary *dic,CCObject* root)
{
	std::string path = jsonName;
	int pos = path.find_last_of("/");
	std::string fileName = path.substr(pos+1,path.length());
	CCLOG("filename == %s",fileName.c_str());
	CCArray* actionList = CCArray::create();
	int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
    for (int i=0; i<actionCount; i++) {
        ActionObject* action = new ActionObject();
		action->autorelease();
        cs::CSJsonDictionary* actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
        action->initWithDictionary(actionDic,root);
        actionList->addObject(action);
		CC_SAFE_DELETE(actionDic);
    }
	m_pActionDic->setObject(actionList, fileName);
}