[LayaAir3]3.3.0.beta.3 2d物理RigidBody代码生成问题
通过代码生成的RigidBody的shapes为undefine(通过浏览器断点查看),在ide里查看也没有shapes属性,通过ide创建的是有的
private addRigidBody(object: Laya.Sprite): Laya.RigidBody {
const rigidBody = object.addComponent(Laya.RigidBody);
rigidBody.type = "kinematic";
rigidBody.label = object.name; // 添加标签
const shape = new Laya.BoxShape2D();
shape.x = object.width / 2;
shape.y = object.height / 2;
shape.width = 1;
shape.height = 1;
rigidBody.shapes = [shape];
return rigidBody;
}
private addRigidBody(object: Laya.Sprite): Laya.RigidBody {
const rigidBody = object.addComponent(Laya.RigidBody);
rigidBody.type = "kinematic";
rigidBody.label = object.name; // 添加标签
const shape = new Laya.BoxShape2D();
shape.x = object.width / 2;
shape.y = object.height / 2;
shape.width = 1;
shape.height = 1;
rigidBody.shapes = [shape];
return rigidBody;
}
没有找到相关结果
已邀请:
1 个回复
layabox
赞同来自:
注意,转换后,不再兼容3.3.0-beta.3以下版本,请注意做好项目备份。