本文整理汇总了C++中ComRender::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ ComRender::setName方法的具体用法?C++ ComRender::setName怎么用?C++ ComRender::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComRender
的用法示例。
在下文中一共展示了ComRender::setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createObject
Node* SceneReader::createObject(cs::JsonDictionary * inputFiles, Node* parenet, ISceneReaderListener* listener)
{
const char *className = inputFiles->getItemStringValue("classname");
if(strcmp(className, "CCNode") == 0)
{
Node* gb = NULL;
if(NULL == parenet)
{
gb = Node::create();
}
else
{
gb = Node::create();
parenet->addChild(gb);
}
setPropertyFromJsonDict(gb, inputFiles);
int count = inputFiles->getArrayItemCount("components");
for (int i = 0; i < count; i++)
{
cs::JsonDictionary * subDict = inputFiles->getSubItemFromArray("components", i);
if (!subDict)
{
CC_SAFE_DELETE(subDict);
break;
}
const char *comName = subDict->getItemStringValue("classname");
const char *pComName = subDict->getItemStringValue("name");
cs::JsonDictionary *fileData = subDict->getSubDictionary("fileData");
std::string pPath;
std::string pPlistFile;
int nResType = 0;
if (fileData != NULL)
{
const char *file = fileData->getItemStringValue("path");
nResType = fileData->getItemIntValue("resourceType", -1);
const char *plistFile = fileData->getItemStringValue("plistFile");
if (file != NULL)
{
pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
}
if (plistFile != NULL)
{
pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile));
}
CC_SAFE_DELETE(fileData);
}
if (comName != NULL && strcmp(comName, "CCSprite") == 0)
{
cocos2d::Sprite *pSprite = NULL;
if (nResType == 0)
{
if (pPath.find(".png") == pPath.npos)
{
continue;
}
pSprite = Sprite::create(pPath.c_str());
}
else if (nResType == 1)
{
std::string pngFile = pPlistFile;
std::string::size_type pos = pngFile.find(".plist");
if (pos == pPath.npos)
{
continue;
}
pngFile.replace(pos, pngFile.length(), ".png");
CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str());
pSprite = Sprite::createWithSpriteFrameName(pPath.c_str());
}
else
{
continue;
}
ComRender *pRender = ComRender::create(pSprite, "CCSprite");
if (pComName != NULL)
{
pRender->setName(pComName);
}
gb->addComponent(pRender);
}
else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0)
{
cocos2d::TMXTiledMap *pTmx = NULL;
if (nResType == 0)
{
if (pPath.find(".tmx") == pPath.npos)
{
continue;
}
pTmx = TMXTiledMap::create(pPath.c_str());
}
else
//.........这里部分代码省略.........