Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void sf_init(Void arg, DefaultGameLoop loop) {
- //A Menu is a collection of MenuItems that are all
- //hooked up to the same mouse/keyboard input
- Menu<Void, Void> menu = new Menu<>();
- //A MenuResult is a container for the result of a
- //menu invocation. When the result gets set, the
- //MenuResult will go into the "done" state and unload
- //the menu.
- MenuResult<Void, Void> result = menu.createResult();
- //A GUIMenuItem is a MenuItem with a visible thing
- //on the screen (a GUIObject).
- //Rendering functions for GUIObjects are pluggable
- //and may each add their own attributes to the
- //GUIObject. (via the set method and an own key)
- //The attributes are anonymous methods to allow for
- //dynamic computation (i.e. for animation)
- GUIMenuItem<Void, Void> guiMenuItem = new GUIMenuItem();
- guiMenuItem.getGUIObject()
- .set(GUIObjectPosition.KEY, o -> makePoint(0.25f, 0.25f))
- .set(GUIObjectSize.KEY, o -> makePoint(0.5f, 0.5f))
- .set(GUIObjectTexture.KEY, o -> "green.png")
- .addRenderingPass(TextureRenderingFunc.getInstance())
- .set(GUIObjectTextSize.KEY, o -> 0.05f)
- .set(GUIObjectTextColor.KEY, o -> Color.white)
- .set(GUIObjectText.KEY, o -> "Wir bitten um Ihre Aufmerksamkeit für einen supertollen Test-Text:\n\nText-Rendering funktioniert, yay! :D")
- .addRenderingPass(TextRenderingFunc.getInstance());
- //Adds the menu item to our menu.
- menu.addMenuItem(guiMenuItem);
- //Shows the menu on the screen.
- menu.show(loop.getMenuContainer());
- //callAndJump = State-machine control (call into first state
- //with argument, then jump into second state with argument
- //after first state returns - Menus plug directly into the
- //game loop state machine and are their own state)
- loop.callAndJump(menu, result, this::sf_done, result);
- }
Add Comment
Please, Sign In to add comment