Jump to content

Bug with TilingSprite._renderCanvas() (context not restored properly)


Skeptron
 Share

Recommended Posts

Hi all,

I'm using Phaser and I came across a glitch which is, I think, due to a bug in the PIXI.TilingSprite.protototype._renderCanvas() method. The bug might be linked to a bad restore of the context.

In my game, once I introduced tiling sprites, everything started to "slide". So I assumed that adding tiling sprites to the game introduced the "sliding" effect in the context. To prove me right I logged "context.currentTransform" at the start and end of the TilingSprite._renderCanvas() method, and I came across that result : 

Start of method : SVGMatrix {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}
End of method : SVGMatrix {a: 1, b: 0, c: 0, d: 1, e: -1255, f: -822}

So as you can see the e and f parameters are different. If I do a context.save() at the start of the method and a context.restore() at the end, everything works perfectly. Same goes if I hardcode context.setTransform(1, 0, 0, 1, 0, 0);

If it helps reproduce the bug, here are the values I have in the method : 

wt = {a: 1, b: 0, c: 0, d: 1, tx: -1255, ty: -822, type: 24}
resolution = 1
tx = -1255
ty = -822

tilePosition = {type: 25, x: 219, y: 0}
tileScale = {type: 25, x: 1, y: 1}

tilePosition.x = 219
tilePosition.y = 0

this._width = 4200
this._height = 2400

I'm not a Pixi expert (first post in this section!), nor in canvas/context, so I'm sorry for any mistake. Also I hope this has not been flagged already!

 

Thanks guys!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...