// var texture = new cc.Texture2D();
// texture.initWithElement(img);
// texture.handleLoadedTexture();
// var newframe = new cc.SpriteFrame(texture);
var renderText = new cc.RenderTexture(size.width,size.height);
renderText.begin();
cc.director.getRunningScene().visit();
renderText.end();
var test = cc.Sprite.create(renderText.getSprite().getTexture(), cc.rect(size.width / 3,size.height / 3 * 2,size.width/3*2,size.height/3*2))//cc.rect的坐标0点是左上角,游戏的坐标0点是左下角
test.setPosition(0, 0)
test.setAnchorPoint(0, 0)
test.setScale(1/2)
this.addChild(test, 10)
var canvas = cc.newElement('canvas') // 创建一个新的元素节点
canvas.width = size.width
canvas.height = size.height
var ctx = canvas.getContext('2d') // 获得一个2d的画布(通过它就可以这个画布上的像素信息,我们只在上面绘制一张图片)
ctx.drawImage(renderText.getSprite().getTexture().getHtmlElementObj(), 0, 0)
var href = canvas.toDataURL("image/png")
// var img = new Image();
//img.src = href;
cc.log(href)