在子域中调用cc.loader.load({url: playerInfo.avatarUrl, type:'png'}, function (err, texture) {}),请求地址会有问题

limichange
Wed, 02 May 2018 05:55:50 +0000

用这个方法，load在子域中没法用，必须使用wx的方法

  setUserAvatar = (sprite: cc.Sprite, avatarUrl: string) => {
    if (avatarUrl) {
      const image = wx.createImage()

      image.onload = function () {
        const texture = new cc.Texture2D()
        texture.initWithElement(image)
        texture.handleLoadedTexture()
        sprite.spriteFrame = new cc.SpriteFrame(texture)
      }

      image.src = avatarUrl
    }
  }

阅读整个主题