Merge pull request #7883 from giginet/set-node-name-via-ccs-scene

Add the feature that CCSSceneReader can load name properties as node names.
This commit is contained in:
minggo 2014-08-28 11:14:15 +08:00
commit f0f1bf1b92
1 changed files with 9 additions and 0 deletions

View File

@ -493,6 +493,9 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d:
float fRotationZ = DICTOOL->getFloatValue_json(root, "rotation"); float fRotationZ = DICTOOL->getFloatValue_json(root, "rotation");
node->setRotation(fRotationZ); node->setRotation(fRotationZ);
const char *sName = DICTOOL->getStringValue_json(root, "name", "");
node->setName(sName);
} }
@ -501,6 +504,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
float x = 0.0f, y = 0.0f, fScaleX = 1.0f, fScaleY = 1.0f, fRotationZ = 1.0f; float x = 0.0f, y = 0.0f, fScaleX = 1.0f, fScaleY = 1.0f, fRotationZ = 1.0f;
bool bVisible = false; bool bVisible = false;
const char *sName = "";
int nTag = 0, nZorder = -1; int nTag = 0, nZorder = -1;
for (int i = 0; i < cocoNode->GetChildNum(); ++i) for (int i = 0; i < cocoNode->GetChildNum(); ++i)
@ -548,6 +552,11 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
fRotationZ = utils::atof(value.c_str()); fRotationZ = utils::atof(value.c_str());
node->setRotation(fRotationZ); node->setRotation(fRotationZ);
} }
else if(key == "name")
{
sName = value.c_str();
node->setName(sName);
}
} }
} }