[LayaAir 2.0]drawToTexture 绘制函数不工作呢
let top_rect: Laya.Sprite = new Laya.Sprite();
top_rect.x = 0;
top_rect.y = 0;
top_rect.size(100, 100);
top_rect.graphics.drawRect(0, 0, 100, 100, "#0000FF", "#000000", 1);
Laya.stage.addChild(top_rect);
let rect_bottom: Laya.Sprite = new Laya.Sprite();
rect_bottom.x = 0;
rect_bottom.y = 0;
rect_bottom.size(100, 100);
rect_bottom.graphics.drawRect(110, 0, 100, 100, "#FF00FF", "#000000", 1);
Laya.stage.addChild(rect_bottom);
//将rect_bottom中的内容绘制到一个texture上面,再将整个texture绘制到
//top_rect上面,显示出来两个的两个矩形应该是一个颜色啊?
let t: Laya.Texture = rect_bottom.drawToTexture(100, 100, 0, 0);
top_rect.graphics.drawTexture(t, 0, 0, 200, 100);
没有找到相关结果
已邀请:
2 个回复
宁远
赞同来自:
宁远
赞同来自:
let img = new Laya.Sprite();
img.size(100,100);
img.x = 400;
img.y = 0;
img.graphics.drawTexture(tex,0,0,100,100);
//img.graphics.drawRect(0,0,50,50,"#000000","#FFFFFF",2);
Laya.stage.addChild(img);
//Laya.loader.getRes("res/atlas/test.png");
//let texcpy:laya.resource.Texture = Laya.loader.getRes("res/atlas/test.png")
let texcpy:laya.resource.Texture = img.drawToTexture(100,100,0,0);
let copyimg:Laya.Sprite = new Laya.Sprite();
copyimg.size(100,100);
copyimg.pos(0,200);
copyimg.graphics.drawTexture(texcpy,0,0,100,100);
Laya.stage.addChild(copyimg);
这样的方式复制的图片也显示不出来