实体跟随相机

This commit is contained in:
yhh
2020-06-08 16:23:48 +08:00
parent f20c460fc6
commit cadd9ab0fc
18 changed files with 925 additions and 54 deletions

View File

@@ -1,7 +1,13 @@
/** 2d 向量 */
class Vector2 {
public x: number;
public y: number;
public x: number = 0;
public y: number = 0;
private static readonly unitVector2 = new Vector2(1, 1);
public static get One(){
return this.unitVector2;
}
/**
* 从两个值构造一个带有X和Y的二维向量。
@@ -43,4 +49,8 @@ class Vector2 {
this.x *= val;
this.y *= val;
}
public static transform(position: Vector2, matrix: Matrix2D){
return new Vector2((position.x * matrix.m11) + (position.y * matrix.m21), (position.x * matrix.m12) + (position.y * matrix.m22));
}
}