Questions about Proton SDK #39
|
Hey! I recently came across Proton SDK, and I've spent the last few days learning to use it. To keep this short, I'd appreciate it if you could help me with a few quick questions:
Thank you for your time. I'm really enjoying working with Proton so far. |
Replies: 2 comments
|
Proton SDK doesn't really have an elegant way to handle GUI sizing exactly (compared to say, Unity's GUI system), but it can be done: 1. UI Element scale: There are two main methods, one is setup a fake screen size and draw everything to that: But that causes issues with incorrect aspect ratios (you could modify the "fake" screensize to at least match the primary screen aspect ratio, that might come out ok.. it sort of depends how many different screen sizes you're targeting and how different they are) Oh, you can also turn "off" the fake screen and do parts of the game/app without it: (for example, GUI buttons scaled to screensize, but the background art is full resolution or something) And other misc helpers for the fake screen stuff: Another more hands on method if the one above is overkill: Calculate positions yourself like this: By assuming the whole the screen is 1024, 768, if you ask for the point at 512, 700, you get "the middle bottom" at the roughly the same place on any screen. Related things but for figuring out how to draw text so it's roughly the same size on different screens: And calculate the scale of button/images themselves like these: 2. Rendering layers In short, no, but also... sort of - all rendering/clickthrough is determined by the hierarchal tree of the entities themselves. ( you can do GetEntityRoot()->PrintTreeAsText(); to see it) So for things like GUI, yes, it's pretty easy to organize them in the Entity tree. Then to move something (an entity, or a whole branch of entities) behind something else you can remove it and reattach it to a different entity (keep in mind an entity can be used as a folder of other entities) : These functions help with that: Proton's rendering itself is just calling "Render" recursively on a tree or branch like this: or this: (for mouse clicks, we go through it backwards, the top thing should be processed first) So if you have a game where you need to constantly change the rendering order, for example, base it on their Y coordinate of little army men running up and down the screen, I'd probably make a Entity::ArmyManRenderer(), and have that keep a list of them, sort them every frame, and have it render all of them by calling my own CustomRender() on them so I could control the order or just that part. Or, maybe I would just write an Entity::SortAllEntitiesUnderThisEntity( send in the entity var we should sort by) function that I call every frame that does actually move them to their correct position, that's kind of nice because then both rendering and mouse click detection on those army men would just function correctly. 3. Default location of new source files I think this is a limitation of Visual Studio and can't be fixed. Sorry! It defaults each session to wherever the .sln is I guess, I mean, maybe if you moved that into /source but ... hrm. |
|
Thanks for taking the time to write such a detailed explanation, this helps a lot! |
Proton SDK doesn't really have an elegant way to handle GUI sizing exactly (compared to say, Unity's GUI system), but it can be done:
1. UI Element scale:
There are two main methods, one is setup a fake screen size and draw everything to that:
But that causes issues with incorrect aspect ratios (you could modify the "fake" screensize to at least match the primary screen aspect ratio, that might come out ok.. it sort of depends how many different screen sizes you're targeting and how different they are)
Oh, you …