Skip to content

Commit 58f7543

Browse files
authored
Merge pull request #2 from tomekzaw/linear-damping
Add linear damping
2 parents dfaeab2 + 1596a36 commit 58f7543

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
@@ -129,6 +129,12 @@ export interface b2Body {
129129
**/
130130
SetLinearVelocity(v: b2Vec2): void;
131131

132+
/**
133+
* Set the linear damping of the body.
134+
* @param linearDamping New linear damping of the body.
135+
**/
136+
SetLinearDamping(linearDamping: number): void;
137+
132138
/**
133139
*
134140
* Set the position of the body's origin and rotation.

0 commit comments

Comments
 (0)