_p = cc.Sprite.prototype;
_p._ctor = function(fileName, rect) {
if (fileName === undefined) {
cc.Sprite.prototype.init.call(this);
}
else if (typeof(fileName) === "string") {
if (fileName[0] === "#") {
//init with a sprite frame name
var frameName = fileName.substr(1, fileName.length - 1);
this.initWithSpriteFrameName(frameName);
} else {
// Create with filename and rect
rect ? this.initWithFile(fileName, rect) : this.initWithFile(fileName);// <<<<<这里
}
}
else if (typeof(fileName) === "object") {
if (fileName instanceof cc.Texture2D) {
//init with texture and rect
rect ? this.initWithTexture(fileName, rect) : this.initWithTexture(fileName);
} else if (fileName instanceof cc.SpriteFrame) {
//init with a sprite frame
this.initWithSpriteFrame(fileName);
} else if (fileName instanceof jsb.PolygonInfo) {
//init with a polygon info
this.initWithPolygon(fileName);
}
}
};
在jsb_create_api.js中由如下代码
在调用this.initWithFile时没对返回值进行检查,所以在Sprite::draw中由于_texture为NULL引起crash。
其他地方或许有类似问题,没有继续测其他的了。