cc.Class({
extends: cc.Component,
properties: {
camera: cc.Camera,
_canvas: null,
_callFunc:null,
},
init () {
var node = new cc.Node();
node.parent = cc.director.getScene();
this.camera = node.addComponent(cc.Camera);
node.anchorX = 0.5;
node.anchorY = 0.5;
node.x = cc.visibleRect.width/2;
node.y = cc.visibleRect.height/2;
var texture = new cc.RenderTexture();
var gl = cc.game._renderContext;
texture.initWithSize(cc.visibleRect.width, cc.visibleRect.height, gl.STENCIL_INDEX8);
//this.camera.cullingMask = 0xffffffff;
this.camera.targetTexture = texture;
this.texture = texture;
this._callFunc = null;
},
// create the img element
initImage () {
// return the type and dataUrl
var dataURL = this._canvas.toDataURL("image/png");
var img = document.createElement("img");
img.src = dataURL;
return img;
},
// create the canvas and context, filpY the image Data
createSprite () {
var width = this.texture.width;
var height = this.texture.height;
if (!this._canvas) {
this._canvas = document.createElement('canvas');
this._canvas.width = width;
this._canvas.height = height;
}
else