| OLD | NEW |
| (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 } | |
| OLD | NEW |