mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added dropping functionality
This commit is contained in:
parent
3f418a1b25
commit
8d34e4a001
2 changed files with 11 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue