mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -05:00
fixed friction in Demo.manipulation
This commit is contained in:
parent
4491dfd5f4
commit
95ae911ed6
1 changed files with 8 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue