cocos2d-js 3.1
在ios8,safari中也无法绘制
错误提示如下:
Uncaught SecurityError: Failed to execute ‘texImage2D’ on ‘WebGLRenderingContext’: The cross-origin image at http://thirdapp2.qlogo.cn/qzopenapp/02421c7a7300de78a00ae84d5a6426f74b6ed3cb61b109f141b8ce9f603eee15/50 may not be loaded.
调用代码:
cc.loader.loadImg(faceurl, {isCrossOrigin : false }, function(err, img){
var texture2d = new cc.Texture2D();
texture2d.initWithElement(img);
texture2d.handleLoadedTexture();
var sprite = new cc.Sprite(texture2d);
sprite.x = this.width / 2 - 2;
sprite.y = this.height / 2 + 4;
sprite.scale = 1.5;
this.addChild(sprite);
Ltc.addSpriteChild(this, res.LaunchFaceBg_png, this.width / 2, this.height / 2);
}.bind(faceBg));
报错位置:
// TexturesWebGL.js
handleLoadedTexture: function () {
…
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self._htmlElementObj);
从网络请求数据可以看到图片已经下载下来了