Layout, to define how your UI is structured, which actor belongs to which and what is their position.Using Scene2D.UI (and Scene2D underneath) there are two things you need to provide: That’s what Scene2D.UI is for - someone’s already done that for you and you have at your disposal a package with common widgets (buttons, labels, lists, etc.) to use. If you wanted to create buttons, tables, labels or, you know, the actual UI, you’d need to create classes for all of these that extend Actor and implement everything that’s necessary. In Scene2D, you only have the Stage, a general Actor class and a Group class. Scene2D.UI is a package that provides common UI widgets and classes built on top of Scene2D. You build your UI by assigning Actors to other Actors, Groups or the Stage directly. Scene2D’s most important classes are: Stage, Actor and Group. You can think of it as the Scene2D being a backend and Scene2D.UI being the frontend. All those Actors you define are only abstract entities that have no graphical form (more on this later). What is important to understand is that Scene2D operates on abstractions. Every element (actor) of your UI belongs to another element and exists only in the scope of his parent. Your whole UI can be expressed in this form, although much more robust. That’s how a very basic graph looks like. Poor button, he’s never seen the world beyond the panel. The button itself consists of a clickable part and the ‘OK’ label. The text and the button only exist in the scope of the panel, they do not know, nor do they need to know, the world beyond it. When you think about it, both the text on the panel and the button are children of the panel - when you move the panel, the text and the button should move along. Imagine a dialog panel with some information and an ‘OK’ button. Scene2D is a 2D scene graph that allows you to layout your actors in a hierarchy and manipulate them as groups. I won’t provide details on the particular tools but I’ll try to provide links where appropriate, so that once you know how everything fits together, you can read how to use this stuff to actually get shit done :) Some details and/or tutorials will probably come in future blog posts. The goal is to show you the tools you have at your disposal when it comes to UI in LibGDX and what their place is in the whole stack. Unfortunately, the docs tell you how to use each particular piece of technology, but they don’t tell you how to combine them and how they come together. I’m not saying LibGDX’s documentation is bad - it’s actually better than most I’ve seen. The reason for that confusion is that there’s a compilation of a few libraries and concepts that create a powerful stack, but you first have to understand the place and use for each of the pieces of that stack - and it’s not properly explained in the documentation how they fit together. That’s how I felt when I tried to make sense of how to properly create a UI in LibGDX. Home About Github 05 June 2017 Lost in LibGDX's UI tools? - maybe this'll help
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |