m4m.framework.rectBody2d
Last updated
Last updated
/ / / / rectBody2d
..rectBody2d
language
zh_CN
classdesc
矩形 2d刚体
version
m4m 1.0
↳ rectBody2d
Inherited from
Defined in
物理世界body
Inherited from
Defined in
• enabled: boolean
= true
language
zh_CN
classdesc
组件启用
version
m4m 1.0
Inherited from
Defined in
Type declaration
▸ (phy2dBody
): any
物理对象初始化完成回调
Parameters
phy2dBody
Returns
any
Inherited from
Defined in
body 选项数据
Inherited from
Defined in
绑定的UI
Overrides
Defined in
▪ Static
Readonly
ClassName: string
= "rectBody2d"
Defined in
▸ addForce(Force
): void
施加作用力
Parameters
Force
Returns
void
Inherited from
Defined in
▸ afterStep(): void
Returns
void
Inherited from
Defined in
▸ beforeStep(): void
Returns
void
Inherited from
Defined in
▸ 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
▸ 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
▸ 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
▸ onPlay(): void
初始化使用 在start 之后
Returns
void
Overrides
Defined in
▸ remove(): void
Returns
void
Inherited from
Defined in
▸ setAngle(angle
): void
设置旋转角度
Parameters
angle
number
Returns
void
Inherited from
Defined in
▸ setAngularVelocity(velocity
): void
设置角速度
Parameters
velocity
number
Returns
void
Inherited from
Defined in
▸ 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
centre
undefined
relative
boolean
false
Returns
void
Inherited from
Defined in
▸ setDensity(Desity
): void
设置密度
Parameters
Desity
number
Returns
void
Inherited from
Defined in
▸ setFriction(friction
): void
设置摩擦力
Parameters
friction
number
Returns
void
Inherited from
Defined in
▸ setFrictionAir(frictionAir
): void
设置空气摩擦力
Parameters
frictionAir
number
Returns
void
Inherited from
Defined in
▸ setFrictionStatic(frictionStatic
): void
设置静态摩擦力
Parameters
frictionStatic
number
Returns
void
Inherited from
Defined in
▸ 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
▸ setInitData(options
): void
设置选项数据
Parameters
options
选项数据
Returns
void
Inherited from
Defined in
▸ setMass(mass
): void
设置质量
Parameters
mass
number
Returns
void
Inherited from
Defined in
▸ 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
parts
undefined
autoHull
boolean
true
Returns
void
Inherited from
Defined in
▸ setPosition(pos
): void
设置位置
Parameters
pos
位置vec2
Returns
void
Inherited from
Defined in
▸ setRestitution(restitution
): void
设置还原张力
Parameters
restitution
number
Returns
void
Inherited from
Defined in
▸ setScale(scale
): void
Parameters
scale
Returns
void
Inherited from
Defined in
▸ setSleeping(isSleeping
): void
设置休眠状态
Parameters
isSleeping
boolean
Returns
void
Inherited from
Defined in
▸ 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
▸ setVelocity(velocity
): void
设置速度
Parameters
velocity
Returns
void
Inherited from
Defined in
▸ 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
Returns
void
Inherited from
Defined in
▸ start(): void
初始化使用
Returns
void
Overrides
Defined in
▸ update(delta
): void
每帧调用一次
Parameters
delta
number
Returns
void
Inherited from
Defined in
• new rectBody2d()
Inherited from
Defined in
2d物理引擎实例对象
Returns
Inherited from
physics2DBody.physicsEngine
Defined in
• get
positionOffset(): vector2
物理对象 碰撞体位置偏移量
Returns
vector2
Inherited from
physics2DBody.positionOffset
Defined in
• set
positionOffset(pos
): void
物理对象 碰撞体位置偏移量
Parameters
pos
vector2
Returns
void
Inherited from
physics2DBody.positionOffset
Defined in
• Protected
_physicsEngine:
.
• body:
.
.
• onInit: (phy2dBody
: ) => any
.
• options: = {}
.
• transform:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
[]
.
.
.
.
.
.
.
[]
.
.
.
.
• get
physicsEngine():