m4m.framework.rectBody2d
@meta4d/engine / Exports / m4m / framework / rectBody2d
Class: rectBody2d
language
zh_CN
classdesc
矩形 2d刚体
version
m4m 1.0
Hierarchy
↳
rectBody2d
Table of contents
Properties
Methods
Constructors
Accessors
Properties
_physicsEngine
• Protected
_physicsEngine: physicEngine2D
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:116
body
• body: Ibody
物理世界body
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:132
enabled
• enabled: boolean
= true
language
zh_CN
classdesc
组件启用
version
m4m 1.0
Inherited from
Defined in
framework/2d/component/behaviour2d.ts:16
onInit
• onInit: (phy2dBody
: I2DPhysicsBody
) => any
Type declaration
▸ (phy2dBody
): any
物理对象初始化完成回调
Parameters
phy2dBody
Returns
any
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:134
options
• options: I2dPhyBodyData
= {}
body 选项数据
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:251
transform
• transform: transform2D
绑定的UI
Overrides
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
Force
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:187
afterStep
▸ afterStep(): void
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:387
beforeStep
▸ beforeStep(): void
Returns
void
Inherited from
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
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
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
Defined in
framework/2d/physicEngine/basebody.ts:172
onPlay
▸ onPlay(): void
初始化使用 在start 之后
Returns
void
Overrides
Defined in
framework/2d/physicEngine/rectBody2d.ts:25
remove
▸ remove(): void
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:452
setAngle
▸ setAngle(angle
): void
设置旋转角度
Parameters
angle
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:285
setAngularVelocity
▸ setAngularVelocity(velocity
): void
设置角速度
Parameters
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
relative
boolean
false
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:359
setDensity
▸ setDensity(Desity
): void
设置密度
Parameters
Desity
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:210
setFriction
▸ setFriction(friction
): void
设置摩擦力
Parameters
friction
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:225
setFrictionAir
▸ setFrictionAir(frictionAir
): void
设置空气摩擦力
Parameters
frictionAir
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:218
setFrictionStatic
▸ setFrictionStatic(frictionStatic
): void
设置静态摩擦力
Parameters
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
Inertia
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:326
setInitData
▸ setInitData(options
): void
设置选项数据
Parameters
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:256
setMass
▸ setMass(mass
): void
设置质量
Parameters
mass
number
Returns
void
Inherited from
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
autoHull
boolean
true
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:348
setPosition
▸ setPosition(pos
): void
设置位置
Parameters
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:264
setRestitution
▸ setRestitution(restitution
): void
设置还原张力
Parameters
restitution
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:239
setScale
▸ setScale(scale
): void
Parameters
scale
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:301
setSleeping
▸ setSleeping(isSleeping
): void
设置休眠状态
Parameters
isSleeping
boolean
Returns
void
Inherited from
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
isStatic
boolean
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:312
setVelocity
▸ setVelocity(velocity
): void
设置速度
Parameters
velocity
Returns
void
Inherited from
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
vertices
Ivec2
[]
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:338
start
▸ start(): void
初始化使用
Returns
void
Overrides
Defined in
framework/2d/physicEngine/rectBody2d.ts:19
update
▸ update(delta
): void
每帧调用一次
Parameters
delta
number
Returns
void
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:367
Constructors
constructor
• new rectBody2d()
Inherited from
Defined in
framework/2d/physicEngine/basebody.ts:118
Accessors
physicsEngine
• get
physicsEngine(): physicEngine2D
2d物理引擎实例对象
Returns
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
pos
vector2
Returns
void
Inherited from
physics2DBody.positionOffset
Defined in
Last updated