Creator版本:1.4.2
运行平台:Web
使用RenderTexture,在update下使用_sgNode.visit()通过访问节点实时把节点下的图片渲染在一个sprite上显示出来的,但是在运行时候,不管我这个被渲染的sprite有没有显示出来,都会增加了和_sgNode.visit()下的节点一样的DrawCall。
本人新手刚接触,请教一下这个是否是正常的呢?
下面是使用的代码:
cc.Class({
extends: cc.Component,
properties: {
sprite: {
default: null,
type: cc.Sprite,
},
spriteList: {
default: [],
type: cc.Sprite,
},
_rt: null,
},
onLoad: function () {
var winSize = cc.director.getWinSize();
this._rt = cc.RenderTexture.create(winSize.width, winSize.height);
this.flipY(this.sprite.node);
},
update: function() {
this.renderTexture();
},
renderTexture: function() {
this._rt.clear(); // this._rt = cc.RenderTexture.create(winSize.width, winSize.height);
this._rt.begin();
for(var i = 0; i < this.spriteList.length; i++) {
this.spriteList[i].node.active = true;
this.spriteList[i].node._sgNode.visit();
this.spriteList[i].node.active = false;
}
this._rt.end();
this.sprite.spriteFrame = this._rt.getSprite().getSpriteFrame();
},
flipY: function(node) {
node.scaleY *= -1;
}
});
在web上运行的显示:
不显示被渲染的sprite:
显示被渲染的sprite:

