mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-02 21:59:09 +08:00
[ts, csharp] Revert RegionAttachment#UpdateOffset from csharp to ts, instead use ts code.
#1889
This commit is contained in:
parent
aa752c49d4
commit
0347c262e0
@ -76,16 +76,12 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOffset () {
|
public void UpdateOffset () {
|
||||||
float width = this.width, height = this.height;
|
float regionScaleX = width / regionOriginalWidth * scaleX;
|
||||||
float scaleX = this.scaleX, scaleY = this.scaleY;
|
float regionScaleY = height / regionOriginalHeight * scaleY;
|
||||||
float localX2 = width * 0.5f;
|
float localX = -width / 2 * scaleX + regionOffsetX * regionScaleX;
|
||||||
float localY2 = height * 0.5f;
|
float localY = -height / 2 * scaleY + regionOffsetY * regionScaleY;
|
||||||
float localX = (-localX2 + regionOffsetX / regionOriginalWidth * width) * scaleX;
|
float localX2 = localX + regionWidth * regionScaleX;
|
||||||
float localY = (-localY2 + regionOffsetY / regionOriginalHeight * height) * scaleY;
|
float localY2 = localY + regionHeight * regionScaleY;
|
||||||
localX2 -= (regionOriginalWidth - regionOffsetX - regionWidth) / regionOriginalWidth * width;
|
|
||||||
localY2 -= (regionOriginalHeight - regionOffsetY - regionHeight) / regionOriginalHeight * height;
|
|
||||||
localX2 *= scaleX;
|
|
||||||
localY2 *= scaleY;
|
|
||||||
float cos = MathUtils.CosDeg(this.rotation);
|
float cos = MathUtils.CosDeg(this.rotation);
|
||||||
float sin = MathUtils.SinDeg(this.rotation);
|
float sin = MathUtils.SinDeg(this.rotation);
|
||||||
float x = this.x, y = this.y;
|
float x = this.x, y = this.y;
|
||||||
|
|||||||
@ -79,16 +79,12 @@ module spine {
|
|||||||
/** Calculates the {@link #offset} using the region settings. Must be called after changing region settings. */
|
/** Calculates the {@link #offset} using the region settings. Must be called after changing region settings. */
|
||||||
updateOffset () : void {
|
updateOffset () : void {
|
||||||
let region = this.region;
|
let region = this.region;
|
||||||
let width = this.width, height = this.height;
|
let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
|
||||||
let scaleX = this.scaleX, scaleY = this.scaleY;
|
let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
|
||||||
let localX2 = width * 0.5;
|
let localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
|
||||||
let localY2 = height * 0.5;
|
let localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
|
||||||
let localX = (-localX2 + region.offsetX / region.originalWidth * width) * scaleX;
|
let localX2 = localX + this.region.width * regionScaleX;
|
||||||
let localY = (-localY2 + region.offsetY / region.originalHeight * height) * scaleY;
|
let localY2 = localY + this.region.height * regionScaleY;
|
||||||
localX2 -= (region.originalWidth - region.offsetX - region.width) / region.originalWidth * width;
|
|
||||||
localY2 -= (region.originalHeight - region.offsetY - region.height) / region.originalHeight * height;
|
|
||||||
localX2 *= scaleX;
|
|
||||||
localY2 *= scaleY;
|
|
||||||
let radians = this.rotation * Math.PI / 180;
|
let radians = this.rotation * Math.PI / 180;
|
||||||
let cos = Math.cos(radians);
|
let cos = Math.cos(radians);
|
||||||
let sin = Math.sin(radians);
|
let sin = Math.sin(radians);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user