diff --git a/demo/dev.html b/demo/dev.html index f3b688b..54ac8da 100644 --- a/demo/dev.html +++ b/demo/dev.html @@ -67,6 +67,7 @@ + diff --git a/demo/js/Demo.js b/demo/js/Demo.js index e7cf592..cd869a5 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -775,8 +775,8 @@ ]); var renderOptions = _engine.render.options; - renderOptions.showAngleIndicator = true; - renderOptions.showCollisions = true; + renderOptions.showAngleIndicator = false; + renderOptions.showVelocity = true; }; Demo.airFriction = function() { @@ -791,8 +791,48 @@ ]); var renderOptions = _engine.render.options; - renderOptions.showAngleIndicator = true; - renderOptions.showCollisions = true; + renderOptions.showAngleIndicator = false; + renderOptions.showVelocity = true; + }; + + Demo.staticFriction = function() { + var _world = _engine.world; + + Demo.reset(); + + var body = Bodies.rectangle(400, 500, 200, 60, { isStatic: true, chamfer: 10 }), + size = 50, + counter = -1; + + var stack = Composites.stack(350, 470 - 6 * size, 1, 6, 0, 0, function(x, y, column, row) { + return Bodies.rectangle(x, y, size * 2, size, { + slop: 0.5, + friction: 1, + frictionStatic: Infinity + }); + }); + + World.add(_world, [body, stack]); + + _sceneEvents.push( + Events.on(_engine, 'beforeUpdate', function(event) { + counter += 0.014; + + if (counter < 0) { + return; + } + + var px = 400 + 100 * Math.sin(counter); + + // body is static so must manually update velocity for friction to work + Body.setVelocity(body, { x: px - body.position.x, y: 0 }); + Body.setPosition(body, { x: px, y: body.position.y }); + }) + ); + + var renderOptions = _engine.render.options; + renderOptions.showAngleIndicator = false; + renderOptions.showVelocity = true; }; Demo.sleeping = function() {