Zeto Posted January 26, 2019 Share Posted January 26, 2019 I know the devs of pixi.js browse this this forum, so just want to say thank you so much for pixi.js! It is an absolutely wonderful framework. I have a simple question and haven't been able to find the answer online. Containers have a width/height which is the total width and height of the sprites in the container, I think. Is there a minX/minY value for the sprites in the container, relative to the position of the container? For example, a container is set to position (20,20). Two sprites inside the container are set to (-10,-10,30,30) as (relX, relY, width, height), and (0,0,40,40). I believe that container.width will be 50, container.height will be 50. Is there a way to find the minX/minY relative to the container (-10,-10)? In other words, I would like to find the bounding rect of the sprites in a container relative to the container itself. Quote Link to comment Share on other sites More sharing options...
xerver Posted January 26, 2019 Share Posted January 26, 2019 I think you are looking for getBounds(): http://pixijs.download/release/docs/PIXI.Container.html#getBounds Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 26, 2019 Share Posted January 26, 2019 relative to container?Yeah, getLocalBounds(). Make sure you understand that this thing invalidates all the transforms inside and changes them temporarily so they are local - it can affect many other operations, lead to strange bugs. Have fun Quote Link to comment Share on other sites More sharing options...
Zeto Posted January 30, 2019 Author Share Posted January 30, 2019 Thank you! getLocalBounds was the function I was looking for. @ivan.popelyshev I don't quite understand your warning, but for the purpose of a simple sprite engine with no transformations whatsoever besides a simple horizontal scale = -1, it has been working well for me! Thank you xerver for the answer too! Cheers 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.