diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index 2965caa..a0174e7 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -2,6 +2,7 @@ import Texture from '../core/textures/Texture'; import CanvasTinter from '../core/sprites/canvas/CanvasTinter'; import TilingShader from './webgl/TilingShader'; +import { Rectangle } from '../core/math'; const tempArray = new Float32Array(4); const tempPoint = new core.Point(); @@ -247,6 +248,38 @@ } /** + * Gets the local bounds of the sprite object. + * + * @param {Rectangle} rect - The output rectangle. + * @return {Rectangle} The bounds. + */ + getLocalBounds(rect) + { + // we can do a fast local bounds if the sprite has no children! + if (this.children.length === 0) + { + this._bounds.minX = -this._width * this.anchor._x; + this._bounds.minY = -this._height * this.anchor._y; + this._bounds.maxX = this._width; + this._bounds.maxY = this._height; + + if (!rect) + { + if (!this._localBoundsRect) + { + this._localBoundsRect = new Rectangle(); + } + + rect = this._localBoundsRect; + } + + return this._bounds.getRectangle(rect); + } + + return super.getLocalBounds.call(this, rect); + } + + /** * Returns the framing rectangle of the sprite as a Rectangle object * * @return {PIXI.Rectangle} the framing rectangle