Hats suck. There I said it.
What exactly are you looking for that hasn’t been posted here before, or isn’t easily achievable by taking that and adapting it? That’s a serious question, btw. Having just got GStreamer bundling working in Praxis, I’m happy to help with (though not write!) something that’s more easily transferable to other code.
Fight! Fight! Fight! Fight! Fight!

No TWL, just literally, two classes: Screen and Area. I extend Screen and override a couple of methods like onClicked and onHovered etc. to deal with things. Screen (and all its Areas) is ticked once per frame, but I use LWJGL input events to actually capture multiple things per tick should they be occurring to quickly.
Cas
So are you using the org.lwjgl.opengl.XRandR or com.badlogic.gdx Screen-class? Sorry if it’s implied in one of the posts, I just want to be sure.
I’m standing in front of an abyss, and on the other side I can see my new menu-framework dancing. I just did one framework in Java2D, which wasn’t too hard and ended up having everything I needed. I know I could just use that as a sort of fullscreen launcher-GUI, which could then start the libgdx-app, but I like the idea of an opengl GUI too. Though it seems very hard and clunky.
I’ve looked at libgdx and their scene2d stuff, and I’m not too happy about how it’s set up. It’s like they’re trying to copy Swing. My 2D framework only requires one line with 10 parameters set, to have a button with text, textcolors it changes between (if you want that when it’s hovered), actions on left-/right-click, font, etc., all of it automatically resizing depending on the resolution. The rest is generalized in a MenuController holding the reins.
If I wanted to do the same type of thing in OpenGL, it seems (at a glance) that I’d have to do some insane juggling of power-of-2-textures which I draw on, drawing my text from a sprite-sheet instead of just using a drawText method (again on a texture?)…or is it a Pixmap?
I liked the fact that I could tell a ui-class how to draw itself when using Java2D. This helped me generalize my MenuController. It seems nigh impossible to have this kind of freedom with any openGL library.
Please tell me I’m just overwhelmed, and that it is not as hard as I’m describing here…I’ve already done a couple of tutorials on this.
No, I’ve got literally two large and complicated classes, Screen, and Area (nothing to do with any other libraries).
Screen amounts to a sprite engine and a collection of Areas. Screens are ticked every frame, which in turn tick all the Areas, and the sprite engine.
Areas are just rectangles which are ticked every frame, and basically just do what they do by looking at the mouse and keyboard input that tick. It’s “simple” and does 95% of all game UI requirements, and the rests, I hack on top.
Cas
Sounds a lot like scene2d in gdx, where Screen=Stage and Area=Actor.
As for scene2d being too much like Swing … in what respect, Charlie? I mean yes, it deals with events and has parent/child relations with widgets, but that’s going to be common to any modern GUI. Hell, it’s more similar to Morphic than it is to Swing.
@Cas: Thanks for the elaboration. Much appreciated. I think I have an idea about what I have to do now.
@sproingie: It’s not that I’m mocking scene2d. It just seems to be rather elaborate and much more split up than what I want to work with. I like simplicity. I only made 4 sections in my Java2D GUI: the objects themselves (Actors), a container (basically a Scene), the resourceholder, and the controller. If a command was not known by the scene itself (on/off switches etc.), it was sent to the controller and handled there.
Hmm, I guess I could frankenstein my way into porting my old system to scene2d, by making my own extensions on Scene and Actor.
Thanks for your inputs. I have much fiddling to do before I try this

I’ve looked at libgdx and their scene2d stuff, and I’m not too happy about how it’s set up. It’s like they’re trying to copy Swing.
gasp choke :o
scene2d has no MVC, so isn’t really like Swing. Each widget is one class, though there is some inheritance. I guess you feel scene2d is daunting at first in a similar way that Swing is? I can assure you it is quite straightforward and simple once you get over the initial hump of “what the hell is all this crap?!”.
Thanks, Cas. Very comprehensive and “bendy” A very good read indeed. Sort of what I had in my Java2D project, only mine was much simpler (less features) and with a lot of subclassing to ease the creative process. You’ve spurred my confidence that I can make this work.
Thanks

For what it’s worth:
Screen.java
Area.javaCas
But… But… STATIC…
Anyway, still have to say, that I enjoyed the RotT source ;D
Actually, forget what I said. scene2d is awesome!
I’ve played around with it a bit now, and with very little effort, you can create your own UI elements, and if you need to create dynamic boxes and such, it is easily extendible.
I only need to get a better understanding of the action-system. I’m having trouble triggering things, but it’s probably just something I’ve missed.
Woohoo!
Actions are described here:
https://code.google.com/p/libgdx/wiki/scene2d#Actions
Let me know which of that is confusing and maybe we can reword things. In a nutshell, there is a simple action class then a few convenience base classes for different action types (eg TemporalAction for stuff that happens over time, etc), then built on top those are a number of common action classes. You can create instances of those yourself, but to make using those more convenient, there is the “Actions” class which has static methods to get configured, pooled action instances.
It is most common and convenient to use the “Actions” class to get instances for sequence, parallel, delay, fade, etc but also keep in mind you can create your own actions. Eg, it is common to extend TemporalAction and implement the begin, update, and/or end methods to do whatever you want. Note to avoid GC you probably want to use Actions.action(Class) to easily get a pooled instance of your action. It will be put back in the pool automatically when it is no longer needed. Lastly, here is an easy way to run some code after some actions:
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
...
sequence(someAction1, someAction2, run(new Runnable() {
public void run () {
// some code
}
}));

Woohoo!
Actions are described here:
bla bla bla VERY NICE STUFF bla bla bla
Thanks a lot for that!
What I was pondering was how hard it would be to do something like this:
- I click a button on my stage (like “Start Game”)
- Then I activate some actions that makes the entire stage fade out
- Then only when the fade-out is complete, does it start the game
How do you intend one does that with your system? If you would be so kind as to maybe just explain in short pseudo-steps, sort of like:
- Make a boolean in your stage
- Use a listener and @Override touchUp to change the boolean
- (somehow) apply an action that fades out the entire stage
- Change to game-screen
EDIT: Oh, wait…I see. You already said that. run()
EDIT 2: Dude, this is AWESOME! I’m so sorry I compared this to Swing. I mean…it’s…I’M SO SORRY!
TextButton button = new TextButton("Some Text", skin);
button.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) {
stage.getRoot().addAction(sequence(fadeOut(4), run(new Runnable() {
public void run () {
// start game
}
})));
}
});
You can get the stage from a field on your class, or event.getStage(), or actor.getStage(), or button.getStage().

EDIT 2: Dude, this is AWESOME! I’m so sorry I compared this to Swing. I mean…it’s…I’M SO SORRY!
LOL ;D
I tried copying your code exactly, and I got the same “problem” I got before. It doesn’t want to accept the run(new Runnable(){summat};
“run” gives an error saying: “The method run(new Runnable(){}) is undefined for the type new ChangeListener(){}”
I’m guessing this is because I’ve cocked something up while setting up my stages or something. It works fine if I just put Actions.run(){summat};
Does this matter?
Once again, you were very right. After climbing that first hump, it’s like “Aaaah, where has this been all my life!?”
Missing static import?
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;

Missing static import?
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
Major facepalm
Of course…
runs along with his new toy
<3 libgdx <3
Yeah the thing to remember in stage2d is that actions are run in parallel unless you explicitly sequence them otherwise – every action means “start doing this NOW”. There is a convenience action now for scheduling actions “after everything else is done” though this can get interesting if you have two of them scheduled (I never did chance to try that scenario)
It’s definitely something quite different than what is normally meant by an Actor system, that’s for sure. But damn is it a lot of fun to play with.