From b92e8e9a607d7698adbc3705c0978164f7db3b8a Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 9 Dec 2019 16:54:52 +0000 Subject: [PATCH] Moved position update to earlier (was too soon) --- src/physics/matter-js/lib/body/Body.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/physics/matter-js/lib/body/Body.js b/src/physics/matter-js/lib/body/Body.js index cb15cd40e..88783420b 100644 --- a/src/physics/matter-js/lib/body/Body.js +++ b/src/physics/matter-js/lib/body/Body.js @@ -45,7 +45,7 @@ var Axes = require('../geometry/Axes'); plugin: {}, angle: 0, vertices: Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40'), - centerOfMass: { x: 0, y: 0 }, + centerOfMass: { x: 0, y: 0 }, // custom Phaser property position: { x: 0, y: 0 }, force: { x: 0, y: 0 }, torque: 0, @@ -108,6 +108,11 @@ var Axes = require('../geometry/Axes'); _original: null }; + if (!options.hasOwnProperty('position') && options.hasOwnProperty('vertices')) + { + options.position = Vertices.centre(options.vertices); + } + var body = Common.extend(defaults, options); _initProperties(body, options); @@ -151,11 +156,6 @@ var Axes = require('../geometry/Axes'); var _initProperties = function(body, options) { options = options || {}; - if (!options.hasOwnProperty('position')) - { - body.position = Vertices.centre(body.vertices); - } - // init required properties (order is important) Body.set(body, { bounds: body.bounds || Bounds.create(body.vertices),