节点层级关系如下
一、加载网络图片
var sprite = this.node.getChildByName('avator').getComponent(cc.Sprite)
cc.loader.load("http://localhost/666.png", function (err, texture) {
//下载用户头像
sprite.spriteFrame = new cc.SpriteFrame(texture);
})
二、加载resources目录下的图片
let that = this
let sprite = that.node.getChildByName('avator').getComponent(cc.Sprite)
sprite.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/prop_666.png'));