Appearance
Class: Vector2
二维向量
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Vector2(num?
)
Parameters
Name | Type |
---|---|
num? | number |
Defined in
• new Vector2(vector2
)
Parameters
Name | Type |
---|---|
vector2 | Vector2 |
Defined in
• new Vector2(x
, y
)
Parameters
Name | Type |
---|---|
x | number |
y | number |
Defined in
Properties
emitter
• emitter: EventEmitter
<string
| symbol
, any
>
Defined in
Accessors
x
• get
x(): number
Returns
number
Defined in
• set
x(val
): void
Parameters
Name | Type |
---|---|
val | number |
Returns
void
Defined in
y
• get
y(): number
Returns
number
Defined in
• set
y(val
): void
Parameters
Name | Type |
---|---|
val | number |
Returns
void
Defined in
Methods
add
▸ add(num
): Vector2
向量加法
Parameters
Name | Type |
---|---|
num | number |
Returns
Defined in
▸ add(x
, y
): Vector2
Parameters
Name | Type |
---|---|
x | number |
y | number |
Returns
Defined in
▸ add(vector2
): Vector2
Parameters
Name | Type |
---|---|
vector2 | Vector2 |
Returns
Defined in
clone
▸ clone(): Vector2
克隆
Returns
Defined in
mul
▸ mul(num
): Vector2
向量缩放
Parameters
Name | Type |
---|---|
num | number |
Returns
Defined in
▸ mul(x
, y
): Vector2
Parameters
Name | Type |
---|---|
x | number |
y | number |
Returns
Defined in
▸ mul(num
): Vector2
向量两个方向分别缩放
Parameters
Name | Type |
---|---|
num | Vector2 |
Returns
Defined in
normalized
▸ normalized(): Vector2
向量归一化
Returns
归一化后的向量
Defined in
set
▸ set(num
): Vector2
Parameters
Name | Type |
---|---|
num | number |
Returns
Defined in
▸ set(x
, y
): Vector2
Parameters
Name | Type |
---|---|
x | number |
y | number |
Returns
Defined in
▸ set(vector2
): Vector2
Parameters
Name | Type |
---|---|
vector2 | Vector2 |
Returns
Defined in
toArray
▸ toArray(): [number
, number
]
Returns
[number
, number
]