Creator1.4 : 单个Graphics的DrawCall数很多是什么问题?

模拟器运行的,GL calls423,这个就是DrawCall吧?按理说一个Graphics不应该就是1吗 再加个背景纯色sprite,应该是2吧?

整个场景就两个节点 一个白色的bg ,一个qrcode,挂载了Graphics,通过Graphics画二维码,画的代码:

	var ctx = this.node.getComponent(cc.Graphics);

	// compute tileW/tileH based on node width and height
	var tileW = this.node.width / qrcode.getModuleCount();
	var tileH = this.node.height / qrcode.getModuleCount();

	// draw in the Graphics
	for (var row = 0; row < qrcode.getModuleCount(); row++) {
		for (var col = 0; col < qrcode.getModuleCount(); col++) {
			if (qrcode.isDark(row, col)) {
				ctx.fillColor = cc.Color.BLACK;
			} else {
				ctx.fillColor = cc.Color.WHITE;
			}
			var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
			var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
			ctx.rect(Math.round(col * tileW), Math.round(row * tileH), w, h);
			ctx.fill();
		}
	}

不过帧数倒一直是60,貌似也没什么影响。。。嗯。。就好奇

1赞

有官方大大解释下吗?

如果这样画二维码drawcall太多的话 我就jsb调android生成二维码并且保存为图片,然后sprite动态加载图片了。。。

对于 graphics 来说,不同颜色的 command 不能够合并 drawcall ,所以把最好同一颜色的命令连起来调用

白的画一个大的,当背景,小的不用画了

1赞

非常感谢~目前就是这么干的~ 只有一个drawcall

我用你这个 就会掉帧特别严重 有什么解决办法呢