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

Side by Side Diff: sky/examples/game/lib/sprite_widget.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 part of sprites;
2
3 /// A widget that uses a [SpriteBox] to render a sprite node tree to the screen.
4 class SpriteWidget extends OneChildRenderObjectWrapper {
5
6 /// The rootNode of the sprite node tree.
7 ///
8 /// var node = mySpriteWidget.rootNode;
9 final NodeWithSize rootNode;
10
11 /// The transform mode used to fit the sprite node tree to the size of the wid get.
12 final SpriteBoxTransformMode transformMode;
13
14 /// Creates a new sprite widget with [rootNode] as its content.
15 ///
16 /// The widget will setup the coordinate space for the sprite node tree using the size of the [rootNode] in
17 /// combination with the supplied [transformMode]. By default the letterbox tr ansform mode is used. See
18 /// [SpriteBoxTransformMode] for more details on the different modes.
19 ///
20 /// The most common way to setup the sprite node graph is to subclass [NodeWit hSize] and pass it to the sprite widget.
21 /// In the custom subclass it's possible to build the node graph, do animation s and handle user events.
22 ///
23 /// var mySpriteTree = new MyCustomNodeWithSize();
24 /// var mySpriteWidget = new SpriteWidget(mySpriteTree, SpriteBoxTransform Mode.fixedHeight);
25 SpriteWidget(this.rootNode, [this.transformMode = SpriteBoxTransformMode.lette rbox]);
26
27 SpriteBox get root => super.root;
28
29 SpriteBox createNode() => new SpriteBox(rootNode, transformMode);
30
31 void syncRenderObject(SpriteWidget old) {
32 super.syncRenderObject(old);
33
34 // SpriteBox doesn't allow mutation of these properties
35 assert(rootNode == root.rootNode);
36 assert(transformMode == root._transformMode);
37 }
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698