From 9fa74400ab9dded8355d182ef371089a2ea970f2 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 30 Apr 2018 12:28:26 +0100 Subject: [PATCH] Container.getBounds now checks if it can call `getBounds` on its children before doing so, as some do not have this method (such as Graphics objects) so they no longer cause the call to crash. Fix #3623 --- src/gameobjects/container/Container.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/container/Container.js b/src/gameobjects/container/Container.js index 3952f19ee..d1d53bcda 100644 --- a/src/gameobjects/container/Container.js +++ b/src/gameobjects/container/Container.js @@ -293,6 +293,9 @@ var Container = new Class({ * Gets the bounds of this Container. It works by iterating all children of the Container, * getting their respective bounds, and then working out a min-max rectangle from that. * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. * * Depending on the quantity of children in this Container it could be a really expensive call, * so cache it and only poll it as needed. @@ -321,9 +324,12 @@ var Container = new Class({ { var entry = children[i]; - entry.getBounds(tempRect); + if (entry.getBounds) + { + entry.getBounds(tempRect); - Union(tempRect, output, output); + Union(tempRect, output, output); + } } }