From 8d34e4a0015a4e40145843ede1cad6548d02a096 Mon Sep 17 00:00:00 2001 From: logsol Date: Wed, 18 Jul 2012 17:48:21 +0200 Subject: [PATCH] added dropping functionality --- joint/common.js | 10 +++++++++- joint/index.html | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/joint/common.js b/joint/common.js index 0e6fa0c..3249ade 100644 --- a/joint/common.js +++ b/joint/common.js @@ -2,6 +2,7 @@ var bodiesNum = 3; var world; var body; var item; +var joint; var b2Vec2 = Box2D.Common.Math.b2Vec2, @@ -62,7 +63,8 @@ function setupWorld(gravity) { jointDef.upperAngle = 0.25 * Math.PI; // 45 degrees jointDef.enableLimit = true; - world.CreateJoint(jointDef); + joint = world.CreateJoint(jointDef); + console.log(joint); /* @@ -93,4 +95,10 @@ function makeBody(width, height, x, y, fixedRotation, mass){ function jump(body) { body.SetAwake(true); body.ApplyImpulse(new b2Vec2(2, -3), body.GetPosition()); +} + + +function drop() { + world.DestroyJoint(joint); + joint = null; } \ No newline at end of file diff --git a/joint/index.html b/joint/index.html index 27a03b8..f96ed1f 100644 --- a/joint/index.html +++ b/joint/index.html @@ -9,7 +9,9 @@ +
+