通过报错的信息可以看出来是资源地址拼错了
下面是我的修改方法
-
scene-1.x.js文件
var loadTexture = function(json, resourcePath, cb){
if(json != null){
var path = json[“path”];
var type = json[“resourceType”];
var plist = json[“plist”];
if(!path)
return;
//if(plist){
// if(cc.loader.getRes(resourcePath + plist)){
// loadedPlist[resourcePath + plist] = true;
// cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
// }else{
// if(!loadedPlist[resourcePath + plist] && !cc.spriteFrameCache.getSpriteFrame(path))
// cc.log("%s need to be preloaded", resourcePath + plist);
// }
//}
// ★源代码有问题, 这里的加载路径被修改过了
var correctPath = “res/” + plist;
if(plist){
if(cc.loader.getRes(correctPath)){
loadedPlist[correctPath] = true;
cc.spriteFrameCache.addSpriteFrames(correctPath);
}else{
if(!loadedPlist[correctPath] && !cc.spriteFrameCache.getSpriteFrame(path))
cc.log("%s need to be preloaded", correctPath);
}
}
if(type !== 0)
cb(path, type);
else
cb(resourcePath + path, type);
}
};
2.timelineParser-2.x.js文件
//var loadTexture = function(json, resourcePath, cb){
// if(json != null){
// var path = json["Path"];
// var type;
// if(json["Type"] === "Default" || json["Type"] === "Normal")
// type = 0;
// else
// type = 1;
// var plist = json["Plist"];
// if(plist){
// if(cc.loader.getRes(resourcePath + plist)){
// loadedPlist[resourcePath + plist] = true;
// cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
// }else{
// if(!loadedPlist[resourcePath + plist] && !cc.spriteFrameCache.getSpriteFrame(path))
// cc.log("%s need to be preloaded", resourcePath + plist);
// }
// }
// if(type !== 0){
// if(cc.spriteFrameCache.getSpriteFrame(path))
// cb(path, type);
// else
// cc.log("failed to get spriteFrame: %s", path);
// }else
// cb(resourcePath + path, type);
// }
//};
// ★修改加载资源bug
var loadTexture = function(json, resourcePath, cb){
if(json != null){
var path = json["Path"];
var type;
if(json["Type"] === "Default" || json["Type"] === "Normal")
type = 0;
else
type = 1;
var plist = json["Plist"];
var correctPath = "res/" + plist;
if(plist){
if(cc.loader.getRes(correctPath)){
loadedPlist[correctPath] = true;
cc.spriteFrameCache.addSpriteFrames(correctPath);
}else{
if(!loadedPlist[correctPath] && !cc.spriteFrameCache.getSpriteFrame(path))
cc.log("%s need to be preloaded", correctPath);
}
}
if(type !== 0){
if(cc.spriteFrameCache.getSpriteFrame(path))
cb(path, type);
else
cc.log("failed to get spriteFrame: %s", path);
}else
cb(correctPath, type);
}
};