From 2c80fad1169e339a91301d886fb9315381dea0e0 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 27 Apr 2020 12:52:36 +0100 Subject: [PATCH] When enabling a Game Object for Input Debugging the created debug shape will now factor in the position, scale and rotation of the Game Objects parent Container, if it has one. #4998 --- src/input/InputPlugin.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 22f315a3f..e3f367589 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -2462,9 +2462,27 @@ var InputPlugin = new Class({ debug.setStrokeStyle(1 / gameObject.scale, color); debug.setDisplayOrigin(gameObject.displayOriginX, gameObject.displayOriginY); - debug.setRotation(gameObject.rotation); - debug.setScale(gameObject.scaleX, gameObject.scaleY); - debug.setPosition(gameObject.getWorldTransformMatrix().tx + offsetx, gameObject.getWorldTransformMatrix().ty + offsety); + + var x = gameObject.x; + var y = gameObject.y; + var rotation = gameObject.rotation; + var scaleX = gameObject.scaleX; + var scaleY = gameObject.scaleY; + + if (gameObject.parentContainer) + { + var matrix = gameObject.getWorldTransformMatrix(); + + x = matrix.tx; + y = matrix.ty; + rotation = matrix.rotation; + scaleX = matrix.scaleX; + scaleY = matrix.scaleY; + } + + debug.setRotation(rotation); + debug.setScale(scaleX, scaleY); + debug.setPosition(x + offsetx, y + offsety); debug.setScrollFactor(gameObject.scrollFactorX, gameObject.scrollFactorY); debug.setDepth(gameObject.depth); };