Skip to content

Commit f4ba7c4

Browse files
committed
Fix wrong Container.getBounds with child container
1 parent 88b088b commit f4ba7c4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/gameobjects/container/Container.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,20 @@ var Container = new Class({
384384

385385
output.setTo(this.x, this.y, 0, 0);
386386

387+
if (this.parentContainer) {
388+
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
389+
var transformedPosition = parentMatrix.transformPoint(this.x, this.y);
390+
output.setTo(transformedPosition.x, transformedPosition.y, 0, 0);
391+
}
392+
387393
if (this.list.length > 0)
388394
{
389395
var children = this.list;
390396
var tempRect = new Rectangle();
391397

392-
for (var i = 0; i < children.length; i++)
398+
var firstChildBounds = children[0].getBounds();
399+
output.setTo(firstChildBounds.x, firstChildBounds.y, firstChildBounds.width, firstChildBounds.height);
400+
for (var i = 1; i < children.length; i++)
393401
{
394402
var entry = children[i];
395403

0 commit comments

Comments
 (0)