Skip to content
On this page

Class: Vector2

二维向量

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Vector2(num?)

Parameters

NameType
num?number

Defined in

src/core/math/Vector2.ts:10

new Vector2(vector2)

Parameters

NameType
vector2Vector2

Defined in

src/core/math/Vector2.ts:11

new Vector2(x, y)

Parameters

NameType
xnumber
ynumber

Defined in

src/core/math/Vector2.ts:12

Properties

emitter

emitter: EventEmitter<string | symbol, any>

Defined in

src/core/math/Vector2.ts:8

Accessors

x

get x(): number

Returns

number

Defined in

src/core/math/Vector2.ts:22

set x(val): void

Parameters

NameType
valnumber

Returns

void

Defined in

src/core/math/Vector2.ts:18


y

get y(): number

Returns

number

Defined in

src/core/math/Vector2.ts:31

set y(val): void

Parameters

NameType
valnumber

Returns

void

Defined in

src/core/math/Vector2.ts:27

Methods

add

add(num): Vector2

向量加法

Parameters

NameType
numnumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:62

add(x, y): Vector2

Parameters

NameType
xnumber
ynumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:63

add(vector2): Vector2

Parameters

NameType
vector2Vector2

Returns

Vector2

Defined in

src/core/math/Vector2.ts:64


clone

clone(): Vector2

克隆

Returns

Vector2

Defined in

src/core/math/Vector2.ts:53


mul

mul(num): Vector2

向量缩放

Parameters

NameType
numnumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:80

mul(x, y): Vector2

Parameters

NameType
xnumber
ynumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:81

mul(num): Vector2

向量两个方向分别缩放

Parameters

NameType
numVector2

Returns

Vector2

Defined in

src/core/math/Vector2.ts:85


normalized

normalized(): Vector2

向量归一化

Returns

Vector2

归一化后的向量

Defined in

src/core/math/Vector2.ts:103


set

set(num): Vector2

Parameters

NameType
numnumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:34

set(x, y): Vector2

Parameters

NameType
xnumber
ynumber

Returns

Vector2

Defined in

src/core/math/Vector2.ts:35

set(vector2): Vector2

Parameters

NameType
vector2Vector2

Returns

Vector2

Defined in

src/core/math/Vector2.ts:36


toArray

toArray(): [number, number]

Returns

[number, number]

Defined in

src/core/math/Vector2.ts:108