cocos creator initWithData 在ios手机上图像无法显示
cocos creator 2.0.10里面 使用Uint8Array去填充出Texture2D的像素数据 在部分手机上正常显示出图片,有些手机上图像不显示 cocos代码: [代码] var[代码] [代码]imgWidth = 200;[代码][代码] [代码][代码]var[代码] [代码]imgHeight = 200;[代码][代码] [代码][代码]var[代码] [代码]count = imgWidth * imgHeight * 4;[代码][代码] [代码][代码]var[代码] [代码]imgData = [代码][代码]new[代码] [代码]Uint8Array(count);[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]j = 0; j < count; j += 4) {[代码][代码] [代码][代码]imgData[j] = Util.randomNum(0, 255);[代码][代码] [代码][代码]imgData[j + 1] = Util.randomNum(0, 255);[代码][代码] [代码][代码]imgData[j + 2] = Util.randomNum(0, 255);[代码][代码] [代码][代码]imgData[j + 3] = 255;[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]var[代码] [代码]myTexture2D = [代码][代码]new[代码] [代码]cc.Texture2D();[代码][代码] [代码][代码]myTexture2D.initWithData(imgData, cc.Texture2D.PixelFormat.RGBA8888, imgWidth, imgHeight);[代码] [代码] [代码][代码]var[代码] [代码]node = [代码][代码]new[代码] [代码]cc.Node([代码][代码]'测试图片'[代码][代码]);[代码][代码] [代码][代码]node.width = imgWidth;[代码][代码] [代码][代码]node.height = imgHeight;[代码][代码] [代码][代码]node.parent = Main.node;[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]sprite = node.addComponent(cc.Sprite);[代码][代码] [代码][代码]sprite.spriteFrame = [代码][代码]new[代码] [代码]cc.SpriteFrame();[代码][代码] [代码][代码]sprite.spriteFrame.setTexture(myTexture2D);[代码]