Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Unified Diff: sky/examples/game/lib/sprite_box.dart

Issue 1177563004: Adds support for zOrder and references to parent nodes in sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/game/lib/game_world.dart ('k') | sky/examples/game/lib/transform_node.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « sky/examples/game/lib/game_world.dart ('k') | sky/examples/game/lib/transform_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698