diff --git a/examples/staticFriction.js b/examples/staticFriction.js index 3ac8091..2d29295 100644 --- a/examples/staticFriction.js +++ b/examples/staticFriction.js @@ -62,6 +62,11 @@ Example.staticFriction = function() { var px = 400 + 100 * Math.sin((engine.timing.timestamp - 1500) * 0.001); + // manual update velocity required for older releases + if (Matter.version === '0.18.0') { + Body.setVelocity(body, { x: px - body.position.x, y: 0 }); + } + Body.setPosition(body, { x: px, y: body.position.y }, true); }); diff --git a/examples/timescale.js b/examples/timescale.js index 3bd8d57..d3c47b3 100644 --- a/examples/timescale.js +++ b/examples/timescale.js @@ -42,15 +42,14 @@ Example.timescale = function() { Bodies.rectangle(0, 300, 50, 600, { isStatic: true }) ]); - var explosion = function(engine, delta) { - var timeScale = delta / 1000; + var explosion = function(engine) { var bodies = Composite.allBodies(engine.world); for (var i = 0; i < bodies.length; i++) { var body = bodies[i]; if (!body.isStatic && body.position.y >= 500) { - // Scale force accounting for time delta. + // Scale force accounting for mass var forceMagnitude = (0.05 * body.mass); Body.applyForce(body, body.position, { @@ -65,7 +64,7 @@ Example.timescale = function() { lastTime = Common.now(); Events.on(engine, 'afterUpdate', function(event) { - var timeScale = timeScale = (event.delta || (1000 / 60)) / 1000; + var timeScale = (event.delta || (1000 / 60)) / 1000; // tween the timescale for bullet time slow-mo engine.timing.timeScale += (timeScaleTarget - engine.timing.timeScale) * 12 * timeScale;