Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cocos/2d/CCTMXXMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ bool TMXMapInfo::parseXMLFile(const std::string& xmlFilename)
}

parser.setDelegator(this);

return parser.parse(FileUtils::getInstance()->fullPathForFilename(xmlFilename));
auto fullPath = FileUtils::getInstance()->fullPathForFilename(xmlFilename);
CCASSERT(FileUtils::getInstance()->isFileExist(fullPath), "TMXMapInfo::parseXMLFile xml file not exists");
return parser.parse(fullPath);
}

// the XML parser calls here with all the elements
Expand Down Expand Up @@ -314,7 +315,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
_currentFirstGID = 0;
}
_recordFirstGID = false;

_externalTilesetFullPath = externalTilesetFilename;
tmxMapInfo->parseXMLFile(externalTilesetFilename);
}
else
Expand Down Expand Up @@ -431,7 +432,12 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
std::string imagename = attributeDict["source"].asString();
tileset->_originSourceImage = imagename;

if (_TMXFileName.find_last_of("/") != string::npos)
if (!_externalTilesetFullPath.empty())
{
string dir = _externalTilesetFullPath.substr(0, _externalTilesetFullPath.find_last_of("/") + 1);
tileset->_sourceImage = dir + imagename;
}
else if (_TMXFileName.find_last_of("/") != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
tileset->_sourceImage = dir + imagename;
Expand Down
1 change: 1 addition & 0 deletions cocos/2d/CCTMXXMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class CC_DLL TMXMapInfo : public Ref, public SAXDelegator
int _currentFirstGID;
bool _recordFirstGID;
std::string _externalTilesetFilename;
std::string _externalTilesetFullPath;
};

// end of tilemap_parallax_nodes group
Expand Down