Skip to content

Commit 2c80fad

Browse files
committed
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. phaserjs#4998
1 parent 3979441 commit 2c80fad

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/input/InputPlugin.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,9 +2462,27 @@ var InputPlugin = new Class({
24622462
debug.setStrokeStyle(1 / gameObject.scale, color);
24632463

24642464
debug.setDisplayOrigin(gameObject.displayOriginX, gameObject.displayOriginY);
2465-
debug.setRotation(gameObject.rotation);
2466-
debug.setScale(gameObject.scaleX, gameObject.scaleY);
2467-
debug.setPosition(gameObject.getWorldTransformMatrix().tx + offsetx, gameObject.getWorldTransformMatrix().ty + offsety);
2465+
2466+
var x = gameObject.x;
2467+
var y = gameObject.y;
2468+
var rotation = gameObject.rotation;
2469+
var scaleX = gameObject.scaleX;
2470+
var scaleY = gameObject.scaleY;
2471+
2472+
if (gameObject.parentContainer)
2473+
{
2474+
var matrix = gameObject.getWorldTransformMatrix();
2475+
2476+
x = matrix.tx;
2477+
y = matrix.ty;
2478+
rotation = matrix.rotation;
2479+
scaleX = matrix.scaleX;
2480+
scaleY = matrix.scaleY;
2481+
}
2482+
2483+
debug.setRotation(rotation);
2484+
debug.setScale(scaleX, scaleY);
2485+
debug.setPosition(x + offsetx, y + offsety);
24682486
debug.setScrollFactor(gameObject.scrollFactorX, gameObject.scrollFactorY);
24692487
debug.setDepth(gameObject.depth);
24702488
};

0 commit comments

Comments
 (0)