Guest User

Untitled

a guest
Jul 16th, 2016
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1.   private void sf_init(Void arg, DefaultGameLoop loop) {
  2.    
  3.     //A Menu is a collection of MenuItems that are all
  4.     //hooked up to the same mouse/keyboard input
  5.     Menu<Void, Void> menu = new Menu<>();
  6.    
  7.     //A MenuResult is a container for the result of a
  8.     //menu invocation. When the result gets set, the
  9.     //MenuResult will go into the "done" state and unload
  10.     //the menu.
  11.     MenuResult<Void, Void> result = menu.createResult();
  12.    
  13.     //A GUIMenuItem is a MenuItem with a visible thing
  14.     //on the screen (a GUIObject).
  15.     //Rendering functions for GUIObjects are pluggable
  16.     //and may each add their own attributes to the
  17.     //GUIObject. (via the set method and an own key)
  18.     //The attributes are anonymous methods to allow for
  19.     //dynamic computation (i.e. for animation)
  20.     GUIMenuItem<Void, Void> guiMenuItem = new GUIMenuItem();
  21.     guiMenuItem.getGUIObject()
  22.             .set(GUIObjectPosition.KEY, o -> makePoint(0.25f, 0.25f))
  23.             .set(GUIObjectSize.KEY, o -> makePoint(0.5f, 0.5f))
  24.             .set(GUIObjectTexture.KEY, o -> "green.png")
  25.             .addRenderingPass(TextureRenderingFunc.getInstance())
  26.             .set(GUIObjectTextSize.KEY, o -> 0.05f)
  27.             .set(GUIObjectTextColor.KEY, o -> Color.white)
  28.             .set(GUIObjectText.KEY, o -> "Wir bitten um Ihre Aufmerksamkeit für einen supertollen Test-Text:\n\nText-Rendering funktioniert, yay! :D")
  29.             .addRenderingPass(TextRenderingFunc.getInstance());
  30.    
  31.     //Adds the menu item to our menu.
  32.     menu.addMenuItem(guiMenuItem);
  33.    
  34.     //Shows the menu on the screen.
  35.     menu.show(loop.getMenuContainer());
  36.    
  37.     //callAndJump = State-machine control (call into first state
  38.     //with argument, then jump into second state with argument
  39.     //after first state returns - Menus plug directly into the
  40.     //game loop state machine and are their own state)
  41.     loop.callAndJump(menu, result, this::sf_done, result);
  42.   }
Add Comment
Please, Sign In to add comment