cc.loader.load远程加载资源错误

下面两种方法打印都是 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));

loader.load( _url, function (err, texture) {
if (!err) {
const spriteFrame = new SpriteFrame();
spriteFrame.texture = texture._texture;
node.getComponent(SpriteComponent).spriteFrame = spriteFrame
}
});

按我这么写就对了.你这个是2d的写法

1赞

感谢感谢,就是这个原因,我有试过texture.texture, 原来是texture._texture,多了个下划线。