0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

fixed friction in Demo.manipulation

This commit is contained in:
liabru 2015-05-09 21:25:01 +01:00
parent 4491dfd5f4
commit 95ae911ed6

View file

@ -445,12 +445,16 @@
Body.setVertices(bodyE, bodyE.vertices); Body.setVertices(bodyE, bodyE.vertices);
} }
// make bodyA move up and down and rotate constantly // make bodyA move up and down
Body.setPosition(bodyA, { x: 100, y: 300 + 100 * Math.sin(_engine.timing.timestamp * 0.005) }); // body is static so must manually update velocity for friction to work
Body.rotate(bodyA, 0.02); 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 // 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); Body.rotate(compound, 0.02);
// every 1.5 sec // every 1.5 sec