[0]图片裁剪,设置textrue的宽高后还是按照原始texteur裁剪,求解!!!
var t = Laya.loader.getRes("res/main/bg/pt1.png") as Laya.Texture;
let clipTexture : Laya.Texture = Laya.Texture.create(this.owner.scene.needImg.texture,this.ptConfig.Typesetting.x,this.ptConfig.Typesetting[i].y,this.ptConfig.Typesetting[i].width,this.ptConfig.Typesetting[i].height);
let sp: Laya.Sprite = new Laya.Sprite();//创建精灵
sp.name = this.ptConfig.Typesetting[i].id.toString();
sp.graphics.drawTexture(clipTexture,0,0,this.ptConfig.Typesetting[i].width,this.ptConfig.Typesetting[i].height);//把截图绘制到精灵上
[/i][/i][/i][/i][/i][/i]
let clipTexture : Laya.Texture = Laya.Texture.create(this.owner.scene.needImg.texture,this.ptConfig.Typesetting.x,this.ptConfig.Typesetting[i].y,this.ptConfig.Typesetting[i].width,this.ptConfig.Typesetting[i].height);
let sp: Laya.Sprite = new Laya.Sprite();//创建精灵
sp.name = this.ptConfig.Typesetting[i].id.toString();
sp.graphics.drawTexture(clipTexture,0,0,this.ptConfig.Typesetting[i].width,this.ptConfig.Typesetting[i].height);//把截图绘制到精灵上
[/i][/i][/i][/i][/i][/i]
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
Laya_Fred
赞同来自:
。我姓颜
赞同来自:
Laya_Fred
赞同来自:
如果是的话,在您创建texture的时候,使用texture.create()传入的参数,从0,0点开始,只截取了148,158绝对宽高的texture大小,所以下面drawtexture的时候就只有这一部分的texture。
在创建texture的时候,不进行裁剪的话直接设置源texture的宽高就可以,在drawtexture里面设置需要绘制的宽高。