瀏覽代碼

[ts][pixi] Use pixi coordinate transformation functions

Davide Tantillo 1 年之前
父節點
當前提交
8e20a5e02b
共有 1 個文件被更改,包括 2 次插入22 次删除
  1. 2 22
      spine-ts/spine-pixi/src/Spine.ts

+ 2 - 22
spine-ts/spine-pixi/src/Spine.ts

@@ -400,32 +400,12 @@ export class Spine extends Container {
 
 	/** Converts a point from the skeleton coordinate system to the Pixi world coordinate system. */
 	skeletonToPixiWorldCoordinates (point: { x: number; y: number }) {
-		let transform = this.worldTransform;
-		let a = transform.a,
-			b = transform.b,
-			c = transform.c,
-			d = transform.d,
-			tx = transform.tx,
-			ty = transform.ty;
-		let x = point.x;
-		let y = point.y;
-		point.x = x * a + y * c + tx;
-		point.y = x * b + y * d + ty;
+		this.worldTransform.apply(point, point);
 	}
 
 	/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
 	pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
-		let transform = this.worldTransform.clone().invert();
-		let a = transform.a,
-			b = transform.b,
-			c = transform.c,
-			d = transform.d,
-			tx = transform.tx,
-			ty = transform.ty;
-		let x = point.x;
-		let y = point.y;
-		point.x = x * a + y * c + tx;
-		point.y = x * b + y * d + ty;
+		this.worldTransform.applyInverse(point, point);
 	}
 
 	/** Converts a point from the Pixi world coordinate system to the bone's local coordinate system. */