[]Spine骨骼动画点击区域偏移 获取不到width height
Spine骨骼动画点击区域偏移 获取不到width height 下面是模型文件
private _factory: Laya.Templet;
constructor(spine, x, y, speed) {
this._factory = new Laya.Templet();
this._factory.loadAni(`../bin/res/spine_model/${spine}.sk`);
this._factory.on(Laya.Event.COMPLETE, this, this.parseComplete, [x, y]);
}
private parseComplete(x, y) {
this._factory.off(Laya.Event.COMPLETE, this, this.parseComplete);
var sprite = this._factory.buildArmature(0);
sprite.x = x;
sprite.y = y;
sprite.scale(0.5,0.5);
sprite.autoSize = true;
sprite.play("idle", true);
Laya.stage.addChild(sprite);
console.log(sprite.getBounds());
console.log(sprite.width,sprite.height));
}
private _factory: Laya.Templet;
constructor(spine, x, y, speed) {
this._factory = new Laya.Templet();
this._factory.loadAni(`../bin/res/spine_model/${spine}.sk`);
this._factory.on(Laya.Event.COMPLETE, this, this.parseComplete, [x, y]);
}
private parseComplete(x, y) {
this._factory.off(Laya.Event.COMPLETE, this, this.parseComplete);
var sprite = this._factory.buildArmature(0);
sprite.x = x;
sprite.y = y;
sprite.scale(0.5,0.5);
sprite.autoSize = true;
sprite.play("idle", true);
Laya.stage.addChild(sprite);
console.log(sprite.getBounds());
console.log(sprite.width,sprite.height));
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
cuixueying
赞同来自:
获取spine的宽高,请使用getBounds方法,可以在sp设置OK后添加一个延迟,在延迟的回调里去获取getBounds的值(保证所有的资源已经加载(创建)完)