textureFromRect method

SpriteTexture textureFromRect (
  1. Rect rect,
  2. [String name]

Creates a new Texture from a part of the current texture.


SpriteTexture textureFromRect(Rect rect, [String name]) {
  assert(rect != null);
  Rect srcFrame = new Rect.fromLTWH(rect.left + frame.left, rect.top + frame.top, rect.size.width, rect.size.height);
  Rect dstFrame = new Rect.fromLTWH(0.0, 0.0, rect.size.width, rect.size.height);
  return new SpriteTexture._fromSpriteFrame(image, name, rect.size, false, false, srcFrame, dstFrame, new Offset(0.5, 0.5));