下面两种方法打印都是 false,,单独打印返回值texure显示为括号里的资源连接,所以frame也不能正常创建
1,跨域没问题,项目和图片都在本地同一IP和端口下。2,资源不缺失
附上代码:
cc.loader.load(‘http://localhost/img.png’, function(err, texture){
if (err) {
cc.error(err.message || err);
return;
}
cc.log('Result should be a Texture2D: ’ + (texture instanceof cc.Texture2D));
}.bind(this));
cc.loader.load({url: 'http://localhost/img.png', type: 'png'}, function(err, texture){
if (err) {
cc.error(err.message || err);
return;
}
cc.log('Result should be a Texture2D: ' + (texture instanceof cc.Texture2D));
var spriteFrame = new cc.SpriteFrame(texture);
this.node.getComponent('cc.SpriteComponent').spriteFrame = spriteFrame;
}.bind(this));