Skip to content

Commit

Permalink
fixed friction in Demo.manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed May 9, 2015
1 parent 4491dfd commit 95ae911
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions demo/js/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,16 @@
Body.setVertices(bodyE, bodyE.vertices);
}

// make bodyA move up and down and rotate constantly
Body.setPosition(bodyA, { x: 100, y: 300 + 100 * Math.sin(_engine.timing.timestamp * 0.005) });
Body.rotate(bodyA, 0.02);
// make bodyA move up and down
// body is static so must manually update velocity for friction to work
var py = 300 + 100 * Math.sin(_engine.timing.timestamp * 0.002);
Body.setVelocity(bodyA, { x: 0, y: py - bodyA.position.y });
Body.setPosition(bodyA, { x: 100, y: py });

// make compound body move up and down and rotate constantly
Body.setPosition(compound, { x: 600, y: 300 + 100 * Math.sin(_engine.timing.timestamp * 0.005) });
Body.setVelocity(compound, { x: 0, y: py - compound.position.y });
Body.setAngularVelocity(compound, 0.02);
Body.setPosition(compound, { x: 600, y: py });
Body.rotate(compound, 0.02);

// every 1.5 sec
Expand Down

0 comments on commit 95ae911

Please sign in to comment.