royibernthal Posted May 24, 2017 Share Posted May 24, 2017 From a little search I noticed there isn't any up-to-date layouts system for Pixi. How do you compensate for that in your projects? This issue mentioned pixi-ui: https://github.com/pixijs/pixi.js/issues/3482 but I couldn't find anything layout related in there: https://github.com/pixijs/pixi-ui Quote Link to comment Share on other sites More sharing options...
Jammy Posted May 24, 2017 Share Posted May 24, 2017 i do it all by scratch everytime and anchor to viewport right/bottom *cries* Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2017 Author Share Posted May 24, 2017 Sounds bad Can you at least nest anchoring and pivoting? Quote Link to comment Share on other sites More sharing options...
Jammy Posted May 24, 2017 Share Posted May 24, 2017 I couldn't find any nice way to do it to be honest. Any 3rd party libs weren't being maintained and I couldn't be bothered coding the solution myself - instead I just have each "gui" in its own function and if the viewport resizing I destroy the GUI and redraw it... Still I'm not happy with that as the solution but I had to crack on with the game itself. So I recorded some resizing so you can see, it has some unpleasant side effects on the actual resize but after that its fairly sound. The code isn't too much of a nightmare to manage but I think my organised codebase helps with that. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2017 Author Share Posted May 24, 2017 Looks like you did a good job there. What do you mean by destroy the GUI then redraw it? Is simply re-adjusting anchors/pivots/positions not enough? Doesn't the redraw happen automatically? Are anchors and pivots relative to their parent the way positions are? Quote Link to comment Share on other sites More sharing options...
Jammy Posted May 24, 2017 Share Posted May 24, 2017 5 hours ago, royibernthal said: Looks like you did a good job there. What do you mean by destroy the GUI then redraw it? Is simply re-adjusting anchors/pivots/positions not enough? Doesn't the redraw happen automatically? Are anchors and pivots relative to their parent the way positions are? I anchor/pivot the positions manually based on view port width and height, no built in pixi help (although I can imagine some way to do it, but I wanted full control). Consider I have a challenge menu. I run game.ui.challengeMenu() to create it, if I ever need to redraw it and let its position change, I just destroy it with game.ui.closeChallengeMenu() then recreate it again with game.ui.challengeMenu(); Since I use game.ui._VIEWPORT_RIGHT [+] (A var which sets itself to viewport width on resize), then all the sprites will be in their new positions when the menu is recreated. I could of course write a "resize/reposition" function for every UI, but that feels like more dev-time, while this isn't the most elegant or efficient it works, you write it once, and then it's done. royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2017 Author Share Posted May 24, 2017 I see, but technically destroying it is not a requirement for it to work. Another option should be to iterate over the menu's items and just modify their positions, correct? I just saw your edit, it answered my question. Thanks Quote Link to comment Share on other sites More sharing options...
Jammy Posted May 24, 2017 Share Posted May 24, 2017 6 minutes ago, royibernthal said: I see, but technically destroying it is not a requirement for it to work. Another option should be to iterate over the menu's items and just modify their positions, correct? I just saw your edit, it answered my question. Thanks Yep, you're completely right. I did wonder like, if I had one overall array/object containing things I might want to reposition then I could reposition them all. But after all the thinking, existing UI's and the pain I'd have trying to manage for example 5 GUI's each within their own "container" kinda thing, then having to update all their position... Even now I struggle to really think of a good solution without creating a real good layout library, at that point im not making my game anymore tho so I have to crack on hahaha. Glad the info helps. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2017 Author Share Posted May 24, 2017 How about separating the creation and positioning logic? Call the positioning on creation and on resize, that way you don't have to deallocate and reallocate memory on each resize. Quote Link to comment Share on other sites More sharing options...
Jammy Posted May 25, 2017 Share Posted May 25, 2017 20 hours ago, royibernthal said: How about separating the creation and positioning logic? Call the positioning on creation and on resize, that way you don't have to deallocate and reallocate memory on each resize. Yup its possible, it adds more coding though for the sake of saving memory when the games resized (which should be rare). I picked saving development time! Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 25, 2017 Author Share Posted May 25, 2017 It adds very little more code, from experience, but since game resizing should be rare as you say I guess it doesn't really matter either way. 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.