Index: sky/examples/game/lib/sprite_box.dart |
diff --git a/sky/examples/game/lib/sprite_box.dart b/sky/examples/game/lib/sprite_box.dart |
index 40ca275110064029317a44937f95b50e775dc389..62e983a432b17a2c1cd4c342c54785311cede0fa 100644 |
--- a/sky/examples/game/lib/sprite_box.dart |
+++ b/sky/examples/game/lib/sprite_box.dart |
@@ -23,9 +23,15 @@ class SpriteBox extends RenderBox { |
double _systemHeight; |
SpriteBox(TransformNode rootNode, [SpriteBoxTransformMode mode = SpriteBoxTransformMode.nativePoints, double width=1024.0, double height=1024.0]) { |
+ assert(rootNode != null); |
+ assert(rootNode._spriteBox == null); |
+ |
// Setup root node |
_rootNode = rootNode; |
+ // Assign SpriteBox reference to all the nodes |
+ _addSpriteBoxReference(_rootNode); |
+ |
// Setup transform mode |
transformMode = mode; |
_systemWidth = width; |
@@ -34,6 +40,13 @@ class SpriteBox extends RenderBox { |
_scheduleTick(); |
} |
+ void _addSpriteBoxReference(TransformNode node) { |
+ node._spriteBox = this; |
+ for (TransformNode child in node._children) { |
+ _addSpriteBoxReference(child); |
+ } |
+ } |
+ |
double get systemWidth => _systemWidth; |
double get systemHeight => _systemHeight; |