Skip to content

Commit 1596a36

Browse files
committed
Add linear damping
1 parent c271062 commit 1596a36

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cpp/JSIBox2dBody.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ namespace Box2d {
6161
return JSIBox2dVec2::toValue(runtime, getObject()->GetLinearVelocity());
6262
}
6363

64+
JSI_HOST_FUNCTION(SetLinearDamping) {
65+
auto linearDamping = arguments[0].asNumber();
66+
getObject()->SetLinearDamping(linearDamping);
67+
return jsi::Value::undefined();
68+
}
69+
6470
JSI_HOST_FUNCTION(SetTransform) {
6571
auto position = JSIBox2dVec2::fromValue(runtime, arguments[0]).get();
6672
auto angle = arguments[1].asNumber();
@@ -92,6 +98,7 @@ namespace Box2d {
9298
JSI_EXPORT_FUNC(JSIBox2dBody, CreateFixture2),
9399
JSI_EXPORT_FUNC(JSIBox2dBody, SetLinearVelocity),
94100
JSI_EXPORT_FUNC(JSIBox2dBody, GetLinearVelocity),
101+
JSI_EXPORT_FUNC(JSIBox2dBody, SetLinearDamping),
95102
JSI_EXPORT_FUNC(JSIBox2dBody, SetTransform),
96103
JSI_EXPORT_FUNC(JSIBox2dBody, ApplyForceToCenter),
97104
JSI_EXPORT_FUNC(JSIBox2dBody, ApplyLinearImpulseToCenter),

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ export interface b2Body {
108108
**/
109109
SetLinearVelocity(v: b2Vec2): void;
110110

111+
/**
112+
* Set the linear damping of the body.
113+
* @param linearDamping New linear damping of the body.
114+
**/
115+
SetLinearDamping(linearDamping: number): void;
116+
111117
/**
112118
*
113119
* Set the position of the body's origin and rotation.

0 commit comments

Comments
 (0)