diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 4dc005a..d60ef70 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -179,6 +179,8 @@ const vertexData = this.vertexData; const trim = texture.trim; const orig = texture.orig; + const anchor = this._anchor; + let w0 = 0; let w1 = 0; let h0 = 0; @@ -188,19 +190,19 @@ { // if the sprite is trimmed and is not a tilingsprite then we need to add the extra // space before transforming the sprite coords. - w1 = trim.x - (this.anchor._x * orig.width); + w1 = trim.x - (anchor._x * orig.width); w0 = w1 + trim.width; - h1 = trim.y - (this.anchor._y * orig.height); + h1 = trim.y - (anchor._y * orig.height); h0 = h1 + trim.height; } else { - w0 = orig.width * (1 - this.anchor._x); - w1 = orig.width * -this.anchor._x; + w0 = orig.width * (1 - anchor._x); + w1 = orig.width * -anchor._x; - h0 = orig.height * (1 - this.anchor._y); - h1 = orig.height * -this.anchor._y; + h0 = orig.height * (1 - anchor._y); + h1 = orig.height * -anchor._y; } // xy @@ -235,6 +237,7 @@ const texture = this._texture; const vertexData = this.vertexTrimmedData; const orig = texture.orig; + const anchor = this._anchor; // lets calculate the new untrimmed bounds.. const wt = this.transform.worldTransform; @@ -245,11 +248,11 @@ const tx = wt.tx; const ty = wt.ty; - const w0 = (orig.width) * (1 - this.anchor._x); - const w1 = (orig.width) * -this.anchor._x; + const w0 = (orig.width) * (1 - anchor._x); + const w1 = (orig.width) * -anchor._x; - const h0 = orig.height * (1 - this.anchor._y); - const h1 = orig.height * -this.anchor._y; + const h0 = orig.height * (1 - anchor._y); + const h1 = orig.height * -anchor._y; // xy vertexData[0] = (a * w1) + (c * h1) + tx;