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)