Tobi Reif Posted January 29, 2016 Share Posted January 29, 2016 In the demo http://codepen.io/TobiReif/full/JGGWZJ this code centers the tree: wavyTree.x = renderer.width / 2 - wavyTree.width / 2; In this version http://codepen.io/TobiReif/pen/84b4ad547bea8e35c04dad641bc890c8/ there's "stage.width" instead of "renderer.width", and the tree is not centered. wavyTree.x = stage.width / 2 - wavyTree.width / 2; The content rendered by "renderer.render(stage)" fills the whole width, so I thought the stage would have the full width as well. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 Stage is container, its not a camera object. There are no camera objects in pixi.js container.width is actually part of container.getLocalBounds() which returns a rectangle that contains all childrens of container in his local coordinates. Are you sure you need that value? Do you understand that wavyTree affects stage.width as well? Quote Link to comment Share on other sites More sharing options...
Tobi Reif Posted January 29, 2016 Author Share Posted January 29, 2016 Now I do - thanks! Is "renderer.width" the right base value for centering stuff? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 28 minutes ago, Tobi Reif said: Is "renderer.width" the right base value for centering stuff? Yep. Quote Link to comment Share on other sites More sharing options...
Tobi Reif Posted January 29, 2016 Author Share Posted January 29, 2016 Thx! 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.