From 795a2fa2ed216e631a9980a4926a5fd98e7bfc69 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 11 Nov 2017 03:51:28 +0000 Subject: [PATCH] Added getCenter to the Bounds component --- v3/src/gameobjects/components/GetBounds.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/v3/src/gameobjects/components/GetBounds.js b/v3/src/gameobjects/components/GetBounds.js index 218413290..ba6eaba90 100644 --- a/v3/src/gameobjects/components/GetBounds.js +++ b/v3/src/gameobjects/components/GetBounds.js @@ -4,6 +4,16 @@ var Vector2 = require('../../math/Vector2'); var GetBounds = { + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + getTopLeft: function (output) { if (output === undefined) { output = new Vector2(); }