waechtertroll Posted October 12, 2016 Share Posted October 12, 2016 Hello, I'm trying to get a coordinate system with (0,0) at the center of the screen. If I understood the API documentation correctly, adding a Container, applying PIXI.Container.setTransform(x, y, scaleX, scaleY, rotation, skewX, skeyY, pivotX, pivotY) and then adding Sprites as children to that Container should apply the transformation to all of them, right? So I created a Container, set x to width/2 and y to height/2, and added Sprites. Problem is, they still appear with (0,0) at top-left corner. Also modifying Container.x/y or Container.position.x/y would not add translations to children Sprites. Of course I could solve the problem by adding the width/2 and height/2 offsets to every sprite I create, but I really think display parameters should be seperated from the model data. What am I doing wrong? Is there a better solution? Quote Link to comment Share on other sites More sharing options...
waechtertroll Posted October 12, 2016 Author Share Posted October 12, 2016 Ah, I SOLVED it. I didn't mention that, but it appeared as root of the problem: I applied scaling and translation to the same Container, so both transforms would influence each other. To achieve my goal, I had to do the following Create a Renderer Create a "root" Container, add it to the Renderer, apply scaling Create a "stage" Container, add it to the "root", apply (now auto-scaled) translation Add graphics into the "stage" Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 12, 2016 Share Posted October 12, 2016 V4 updates transforms lazily. You have to call updateTransform() on it. All methods like getBounds(), toLocal(), toGlobal() also are calling it to ensure that transform is updated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.