SpriteBox constructor

SpriteBox(NodeWithSize rootNode, [ SpriteBoxTransformMode mode = SpriteBoxTransformMode.letterbox ])

Creates a new SpriteBox with a node as its content, by default uses letterboxing.

The rootNode provides the content of the node tree, typically it's a custom subclass of NodeWithSize. The mode provides different ways to scale the content to best fit it to the screen. In most cases it's preferred to use a SpriteWidget that automatically wraps the SpriteBox.

var spriteBox = new SpriteBox(myNode, SpriteBoxTransformMode.fixedHeight);

Implementation

SpriteBox(NodeWithSize rootNode, [SpriteBoxTransformMode mode = SpriteBoxTransformMode.letterbox]) {
  assert(rootNode != null);
  assert(rootNode._spriteBox == null);

  // Setup transform mode
  this.transformMode = mode;

  // Setup root node
  this.rootNode = rootNode;
}