SpriteBox constructor

SpriteBox({
  1. required NodeWithSize rootNode,
  2. SpriteBoxTransformMode transformMode = 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 transformMode 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 = SpriteBox(myNode, SpriteBoxTransformMode.fixedHeight);

Implementation

SpriteBox({
  required NodeWithSize rootNode,
  SpriteBoxTransformMode transformMode = SpriteBoxTransformMode.letterbox,
}) {
  // Setup transform mode
  _transformMode = transformMode;
  // this.transformMode = mode;

  // Setup root node
  _rootNode = rootNode;
  _addSpriteBoxReference(_rootNode);
}