Skip to content

Commit 1b95406

Browse files
committed
Merge pull request phaserjs#247 from cocoademon/trim_fix
Switch method of using trimmed sprites to support scaling and rotation
2 parents da5d8c9 + 8469a9c commit 1b95406

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/PixiPatch.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,18 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
6363
if (displayObject.texture.frame)
6464
{
6565
this.context.globalAlpha = displayObject.worldAlpha;
66+
67+
this.context.setTransform(
68+
displayObject.worldTransform[0],
69+
displayObject.worldTransform[3],
70+
displayObject.worldTransform[1],
71+
displayObject.worldTransform[4],
72+
displayObject.worldTransform[2],
73+
displayObject.worldTransform[5]);
6674

6775
if (displayObject.texture.trimmed)
6876
{
69-
this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2] + displayObject.texture.trim.x, displayObject.worldTransform[5] + displayObject.texture.trim.y);
70-
}
71-
else
72-
{
73-
this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]);
77+
this.context.transform(1, 0, 0, 1, displayObject.texture.trim.x, displayObject.texture.trim.y);
7478
}
7579

7680
this.context.drawImage(

0 commit comments

Comments
 (0)