From bf90bdd38c5e2d6c39f60b8446a182b1c0ccf498 Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 26 Dec 2021 16:58:49 +0000 Subject: [PATCH] use Body.getVelocity in Matter.Render --- src/render/Render.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/render/Render.js b/src/render/Render.js index ae52040..ab8dcf7 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -10,6 +10,7 @@ var Render = {}; module.exports = Render; +var Body = require('../body/Body'); var Common = require('../core/Common'); var Composite = require('../body/Composite'); var Bounds = require('../geometry/Bounds'); @@ -1106,8 +1107,10 @@ var Mouse = require('../core/Mouse'); if (!body.render.visible) continue; + var velocity = Body.getVelocity(body); + c.moveTo(body.position.x, body.position.y); - c.lineTo(body.position.x + (body.position.x - body.positionPrev.x) * 2, body.position.y + (body.position.y - body.positionPrev.y) * 2); + c.lineTo(body.position.x + velocity.x * 2, body.position.y + velocity.y * 2); } c.lineWidth = 3;