Merge pull request #766 from natural-law/issue3268

Solve the error effect of TiledMap in Windows Creator.
This commit is contained in:
Jare Guo
2016-06-03 17:16:03 +08:00
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -695,6 +695,14 @@ var TiledMap = cc.Class({
if (file) {
var resPath = cc.url._rawAssets + file.tmxFolderPath;
resPath = cc.path._setEndWithSep(resPath, false);
if (CC_EDITOR && cc.sys.os === cc.sys.OS_WINDOWS) {
// In windows editor, the key of loaded textures are using '/'.
// But the value of cc.url._rawAssets is using '\'
// So, here should change the separater.
resPath = resPath.replace(/\\/g, '/');
}
var ret = sgNode.initWithXML(file.tmxXmlStr, resPath);
if (ret) {
self._onMapLoaded();
+1 -1
View File
@@ -94,7 +94,7 @@ class TiledMapMeta extends CustomAssetMeta {
asset.name = Path.basenameNoExt(fspath);
asset.tmxXmlStr = this._tmxData;
asset.tmxFolderPath = Path.relative(AssetRootUrl, Url.dirname(db.fspathToUrl(fspath)));
asset.tmxFolderPath = asset.tmxFolderPath.replace('\\', '/');
asset.tmxFolderPath = asset.tmxFolderPath.replace(/\\/g, '/');
asset.textures = this._textures.map(p => db.fspathToUrl(p));
asset.tsxFiles = this._tsxFiles.map(p => db.fspathToUrl(p));
db.saveAssetToLibrary(this.uuid, asset);