[code]// test drawToCanvas
const sp1 = new Sprite();
sp1.loadImage('bet/cheer_1_3.png');
const sp2 = new Sprite();
sp2.x = 100;
sp2.loadImage('bet/cheer_1_4.png');
sp1.addChild(sp2);
this.addChild(sp1);
const htmlCanvas = sp1.drawToCanvas(640, 200, 0, 0);
const canvas = htmlCanvas.getCanvas();
trace(canvas.toDataURL('image/png'));
const texture = new Laya.Texture(htmlCanvas);
const sp = new Sprite();
sp.graphics.drawTexture(texture);
this.shot.addChild(sp);[/code]对,是可以的。当时drawToCanvas的第一个参数设置小了,没看到后面的元素。
这里还有一个问题:
[code] const sp1 = new Laya.Image();
sp1.skin = 'bet/cheer_1_3.png';
this.addChild(sp1);
const htmlCanvas = sp1.drawToCanvas(640, 200, 0, 0);
const canvas = htmlCanvas.getCanvas();
trace(canvas.toDataURL('image/png'));
const texture = new Laya.Texture(htmlCanvas);
const sp = new Sprite();
sp.graphics.drawTexture(texture);
this.shot.addChild(sp);[/code]为什么我这里sp1是Image类,无法截图。