1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| let assetDefault = "CommonText"; // 默认语言的图集 let assetChange = "CommonText_HIN"; // 要切换的语言图集 let assetUrlDefault = "texture/" + assetDefault; cc.loader.loadRes(assetUrlDefault, cc.SpriteAtlas, (err, lastAsset) => { // 加载默认图集 let assetUrlChange = "texture/" + assetArr[game.player.language - 1]; cc.loader.loadRes(assetUrlChange, cc.SpriteAtlas, (err, curAsset) => { // 加载新图集 // 循环替换新图集的图片给默认图片 for (let key in lastAsset._spriteFrames) { let lastSP = lastAsset._spriteFrames[key]; let curSP = curAsset._spriteFrames[key]; for (let i in lastSP) { if (!(lastSP[i] instanceof Function) && i != "isValid" && i != "nativeUrl" && i != "_uuid") { lastSP[i] = curSP[i]; } } } }); });
|