GBagley Posted June 20, 2015 Share Posted June 20, 2015 Is there a simple way to get the on-screen position (in pixels) for a PIXI.Graphics() object? I've been calculating this myself in some cases, but it's a bit of a pain when there are many nested containers, each with their own offsets and scaling. Wondering if the screen position is something I can pull more directly from the object, or if there is something else in PIXI that would help calculate this. Thanks! Quote Link to comment Share on other sites More sharing options...
xerver Posted June 20, 2015 Share Posted June 20, 2015 I think you are looking for `.toGlobal()`: http://pixijs.github.io/docs/PIXI.DisplayObject.html#toGlobalhttps://github.com/GoodBoyDigital/pixi.js/blob/master/src/core/display/DisplayObject.js#L370-L381 Quote Link to comment Share on other sites More sharing options...
GBagley Posted June 21, 2015 Author Share Posted June 21, 2015 Maybe I'm missing something. That seems to return the global (world) position, rather than the screen position. Quote Link to comment Share on other sites More sharing options...
xerver Posted June 22, 2015 Share Posted June 22, 2015 Correct, you can use the global (world) position to calculate the screen position. You mentioned having to calculate the world position yourself, and you don't need to you can use this function for that. 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.