mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
23 lines
691 B
JavaScript
23 lines
691 B
JavaScript
|
(function() {
|
||
|
|
||
|
var World = Matter.World,
|
||
|
Body = Matter.Body,
|
||
|
Composites = Matter.Composites;
|
||
|
|
||
|
Example.newtonsCradle = function(demo) {
|
||
|
var engine = demo.engine,
|
||
|
world = engine.world;
|
||
|
|
||
|
var cradle = Composites.newtonsCradle(280, 100, 5, 30, 200);
|
||
|
World.add(world, cradle);
|
||
|
Body.translate(cradle.bodies[0], { x: -180, y: -100 });
|
||
|
|
||
|
cradle = Composites.newtonsCradle(280, 380, 7, 20, 140);
|
||
|
World.add(world, cradle);
|
||
|
Body.translate(cradle.bodies[0], { x: -140, y: -100 });
|
||
|
|
||
|
var renderOptions = engine.render.options;
|
||
|
renderOptions.showVelocity = true;
|
||
|
};
|
||
|
|
||
|
})();
|