[]image在相应loaded的时候,无法正确获取高度
class RoleUIDynamic extends Laya.Image
{
matterBody: Matter.Body;
constructor()
{
super();
this.on('start', this, this.init);
}
private init():void
{
console.log("init", this.x, this.y, this.width, this.height, this.scaleX, this.scaleY);
var createOption: any =
{
isStatic: false,
};
this.matterBody = Matter.Bodies.rectangle(this.x, this.y, this.width, this.height, createOption);
Matter.World.add(GameMain.instance.engine.world, this.matterBody);
this.matterBody.layaSprite = this;
Matter.Events.on(GameMain.instance.engine, 'beforeUpdate', (()=>
{
console.log("update", this.x, this.y, this.width, this.height)
}).bind(this));
}
第一个打印,this.height是没有形变时候的参数,只有执行了一次update时,获得的this.height才正确。 假设我想用matter创建一个正确大小的body给编辑器里拖出来的image,我该如何初始化 谢谢
{
matterBody: Matter.Body;
constructor()
{
super();
this.on('start', this, this.init);
}
private init():void
{
console.log("init", this.x, this.y, this.width, this.height, this.scaleX, this.scaleY);
var createOption: any =
{
isStatic: false,
};
this.matterBody = Matter.Bodies.rectangle(this.x, this.y, this.width, this.height, createOption);
Matter.World.add(GameMain.instance.engine.world, this.matterBody);
this.matterBody.layaSprite = this;
Matter.Events.on(GameMain.instance.engine, 'beforeUpdate', (()=>
{
console.log("update", this.x, this.y, this.width, this.height)
}).bind(this));
}
第一个打印,this.height是没有形变时候的参数,只有执行了一次update时,获得的this.height才正确。 假设我想用matter创建一个正确大小的body给编辑器里拖出来的image,我该如何初始化 谢谢
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Aar0n
赞同来自: