m4m.framework.rectBody2d

@meta4d/engine / Exports / m4m / framework / rectBody2d

Class: rectBody2d

m4m.framework.rectBody2d

language zh_CN

classdesc 矩形 2d刚体

version m4m 1.0

Hierarchy

Table of contents

Properties

Methods

Constructors

Accessors

Properties

_physicsEngine

Protected _physicsEngine: physicEngine2D

Inherited from

physics2DBody._physicsEngine

Defined in

framework/2d/physicEngine/basebody.ts:116


body

body: Ibody

物理世界body

Inherited from

physics2DBody.body

Defined in

framework/2d/physicEngine/basebody.ts:132


enabled

enabled: boolean = true

language zh_CN

classdesc 组件启用

version m4m 1.0

Inherited from

physics2DBody.enabled

Defined in

framework/2d/component/behaviour2d.ts:16


onInit

onInit: (phy2dBody: I2DPhysicsBody) => any

Type declaration

▸ (phy2dBody): any

物理对象初始化完成回调

Parameters

Name
Type

Returns

any

Inherited from

physics2DBody.onInit

Defined in

framework/2d/physicEngine/basebody.ts:134


options

options: I2dPhyBodyData = {}

body 选项数据

Inherited from

physics2DBody.options

Defined in

framework/2d/physicEngine/basebody.ts:251


transform

transform: transform2D

绑定的UI

Overrides

physics2DBody.transform

Defined in

framework/2d/physicEngine/rectBody2d.ts:17


ClassName

Static Readonly ClassName: string = "rectBody2d"

Defined in

framework/2d/physicEngine/rectBody2d.ts:16

Methods

addForce

addForce(Force): void

施加作用力

Parameters

Name
Type

Force

Returns

void

Inherited from

physics2DBody.addForce

Defined in

framework/2d/physicEngine/basebody.ts:187


afterStep

afterStep(): void

Returns

void

Inherited from

physics2DBody.afterStep

Defined in

framework/2d/physicEngine/basebody.ts:387


beforeStep

beforeStep(): void

Returns

void

Inherited from

physics2DBody.beforeStep

Defined in

framework/2d/physicEngine/basebody.ts:371


isSensor

isSensor(): boolean

是否是传感器 A flag that indicates whether a body is a sensor. Sensor triggers collision events, but doesn't react with colliding body physically.

Returns

boolean

Inherited from

physics2DBody.isSensor

Defined in

framework/2d/physicEngine/basebody.ts:179


isSleeping

isSleeping(): boolean

是否已休眠 A flag that indicates whether the body is considered sleeping. A sleeping body acts similar to a static body, except it is only temporary and can be awoken. If you need to set a body as sleeping, you should use Sleeping.set as this requires more than just setting this flag.

Returns

boolean

Inherited from

physics2DBody.isSleeping

Defined in

framework/2d/physicEngine/basebody.ts:164


isStatic

isStatic(): boolean

是否是静态 A flag that indicates whether a body is considered static. A static body can never change position or angle and is completely fixed. If you need to set a body as static after its creation, you should use Body.setStatic as this requires more than just setting this flag.

Returns

boolean

Inherited from

physics2DBody.isStatic

Defined in

framework/2d/physicEngine/basebody.ts:172


onPlay

onPlay(): void

初始化使用 在start 之后

Returns

void

Overrides

physics2DBody.onPlay

Defined in

framework/2d/physicEngine/rectBody2d.ts:25


remove

remove(): void

Returns

void

Inherited from

physics2DBody.remove

Defined in

framework/2d/physicEngine/basebody.ts:452


setAngle

setAngle(angle): void

设置旋转角度

Parameters

Name
Type

angle

number

Returns

void

Inherited from

physics2DBody.setAngle

Defined in

framework/2d/physicEngine/basebody.ts:285


setAngularVelocity

setAngularVelocity(velocity): void

设置角速度

Parameters

Name
Type

velocity

number

Returns

void

Inherited from

physics2DBody.setAngularVelocity

Defined in

framework/2d/physicEngine/basebody.ts:202


setCentre

setCentre(centre, relative?): void

设置中心点 Set the centre of mass of the body. The centre is a vector in world-space unless relative is set, in which case it is a translation. The centre of mass is the point the body rotates about and can be used to simulate non-uniform density. This is equal to moving body.position but not the body.vertices. Invalid if the centre falls outside the body's convex hull.

Parameters

Name
Type
Default value

centre

undefined

relative

boolean

false

Returns

void

Inherited from

physics2DBody.setCentre

Defined in

framework/2d/physicEngine/basebody.ts:359


setDensity

setDensity(Desity): void

设置密度

Parameters

Name
Type

Desity

number

Returns

void

Inherited from

physics2DBody.setDensity

Defined in

framework/2d/physicEngine/basebody.ts:210


setFriction

setFriction(friction): void

设置摩擦力

Parameters

Name
Type

friction

number

Returns

void

Inherited from

physics2DBody.setFriction

Defined in

framework/2d/physicEngine/basebody.ts:225


setFrictionAir

setFrictionAir(frictionAir): void

设置空气摩擦力

Parameters

Name
Type

frictionAir

number

Returns

void

Inherited from

physics2DBody.setFrictionAir

Defined in

framework/2d/physicEngine/basebody.ts:218


setFrictionStatic

setFrictionStatic(frictionStatic): void

设置静态摩擦力

Parameters

Name
Type

frictionStatic

number

Returns

void

Inherited from

physics2DBody.setFrictionStatic

Defined in

framework/2d/physicEngine/basebody.ts:232


setInertia

setInertia(Inertia): void

设置惯性值 Sets the moment of inertia (i.e. second moment of area) of the body. Inverse inertia is automatically updated to reflect the change. Mass is not changed.

Parameters

Name
Type

Inertia

number

Returns

void

Inherited from

physics2DBody.setInertia

Defined in

framework/2d/physicEngine/basebody.ts:326


setInitData

setInitData(options): void

设置选项数据

Parameters

Name
Type
Description

options

选项数据

Returns

void

Inherited from

physics2DBody.setInitData

Defined in

framework/2d/physicEngine/basebody.ts:256


setMass

setMass(mass): void

设置质量

Parameters

Name
Type

mass

number

Returns

void

Inherited from

physics2DBody.setMass

Defined in

framework/2d/physicEngine/basebody.ts:247


setParts

setParts(parts, autoHull?): void

设置成员 Sets the parts of the body and updates mass, inertia and centroid. Each part will have its parent set to body. By default the convex hull will be automatically computed and set on body, unless autoHull is set to false. Note that this method will ensure that the first part in body.parts will always be the body.

Parameters

Name
Type
Default value

parts

undefined

autoHull

boolean

true

Returns

void

Inherited from

physics2DBody.setParts

Defined in

framework/2d/physicEngine/basebody.ts:348


setPosition

setPosition(pos): void

设置位置

Parameters

Name
Type
Description

pos

位置vec2

Returns

void

Inherited from

physics2DBody.setPosition

Defined in

framework/2d/physicEngine/basebody.ts:264


setRestitution

setRestitution(restitution): void

设置还原张力

Parameters

Name
Type

restitution

number

Returns

void

Inherited from

physics2DBody.setRestitution

Defined in

framework/2d/physicEngine/basebody.ts:239


setScale

setScale(scale): void

Parameters

Name
Type

scale

Returns

void

Inherited from

physics2DBody.setScale

Defined in

framework/2d/physicEngine/basebody.ts:301


setSleeping

setSleeping(isSleeping): void

设置休眠状态

Parameters

Name
Type

isSleeping

boolean

Returns

void

Inherited from

physics2DBody.setSleeping

Defined in

framework/2d/physicEngine/basebody.ts:318


setStatic

setStatic(isStatic): void

设置静态状态 Sets the body as static, including isStatic flag and setting mass and inertia to Infinity.

Parameters

Name
Type

isStatic

boolean

Returns

void

Inherited from

physics2DBody.setStatic

Defined in

framework/2d/physicEngine/basebody.ts:312


setVelocity

setVelocity(velocity): void

设置速度

Parameters

Name
Type

velocity

Returns

void

Inherited from

physics2DBody.setVelocity

Defined in

framework/2d/physicEngine/basebody.ts:194


setVertices

setVertices(vertices): void

设置顶点 Sets the body's vertices and updates body properties accordingly, including inertia, area and mass (with respect to body.density). Vertices will be automatically transformed to be orientated around their centre of mass as the origin. They are then automatically translated to world space based on body.position.

The vertices argument should be passed as an array of Matter.Vector points (or a Matter.Vertices array). Vertices must form a convex hull, concave hulls are not supported.

Parameters

Name
Type

vertices

Returns

void

Inherited from

physics2DBody.setVertices

Defined in

framework/2d/physicEngine/basebody.ts:338


start

start(): void

初始化使用

Returns

void

Overrides

physics2DBody.start

Defined in

framework/2d/physicEngine/rectBody2d.ts:19


update

update(delta): void

每帧调用一次

Parameters

Name
Type

delta

number

Returns

void

Inherited from

physics2DBody.update

Defined in

framework/2d/physicEngine/basebody.ts:367

Constructors

constructor

new rectBody2d()

Inherited from

physics2DBody.constructor

Defined in

framework/2d/physicEngine/basebody.ts:118

Accessors

physicsEngine

get physicsEngine(): physicEngine2D

2d物理引擎实例对象

Returns

physicEngine2D

Inherited from

physics2DBody.physicsEngine

Defined in

framework/2d/physicEngine/basebody.ts:109


positionOffset

get positionOffset(): vector2

物理对象 碰撞体位置偏移量

Returns

vector2

Inherited from

physics2DBody.positionOffset

Defined in

framework/2d/physicEngine/basebody.ts:138

set positionOffset(pos): void

物理对象 碰撞体位置偏移量

Parameters

Name
Type

pos

vector2

Returns

void

Inherited from

physics2DBody.positionOffset

Defined in

framework/2d/physicEngine/basebody.ts:139

Last updated