diff --git a/cocos2d/tilemap/CCTiledMap.js b/cocos2d/tilemap/CCTiledMap.js index 726d1aa0dc..ab3822998c 100644 --- a/cocos2d/tilemap/CCTiledMap.js +++ b/cocos2d/tilemap/CCTiledMap.js @@ -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(); diff --git a/cocos2d/tilemap/editor/tiled-map.js b/cocos2d/tilemap/editor/tiled-map.js index 8294b0f3db..0b60f2dda9 100644 --- a/cocos2d/tilemap/editor/tiled-map.js +++ b/cocos2d/tilemap/editor/tiled-map.js @@ -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);