如果做微信小游戏好友排行榜?

如何在子域中绘制玩家微信头像?(不用微信提供的api,我想用cocos控件来显示)

我是参考cocos提供的方案,在子域中用cocos控件做了一个viewlist,涉及到头像的代码如下:
cc.loader.load(userData.avatarUrl, function(err, texture){
console.log("load download_url = ", userData.avatarUrl);
var MyHeadSprite = new cc.SpriteFrame(texture);
this.head.spriteFrame = MyHeadSprite;
}.bind(this));

结果报错了:
gameSubContextThirdScriptError
fs.access is not a function;at requestAnimationFrame callback function
TypeError: fs.access is not a function

穿件微信头像是不是只能用wx.createImage()???
如果是这样的话,cocos提供的子域方案不是没用?
@panda

createImage(sprite,url){
let image = wx.createImage();
image.onload = function () {
let texture = new cc.Texture2D();
texture.initWithElement(image);
texture.handleLoadedTexture();
sprite.spriteFrame = new cc.SpriteFrame(texture);
};
image.src = url;
}

已解决,如上

1赞

这个createImage是放在update里面的吧,我现在做,排行榜功能是可以了,但是在部分机型上会很卡,请问你有遇到么