Beispiel #1
0
  @Override
  public void simpleInitApp() {
    NiftyJmeDisplay niftyDisplay =
        new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    Nifty nifty = niftyDisplay.getNifty();
    guiViewPort.addProcessor(niftyDisplay);
    flyCam.setDragToRotate(true);

    nifty.loadStyleFile("nifty-default-styles.xml");
    nifty.loadControlFile("nifty-default-controls.xml");

    // <screen>
    nifty.addScreen(
        "Screen_ID",
        new ScreenBuilder("Hello Nifty Screen") {
          {
            controller(new DefaultScreenController()); // Screen properties

            // <layer>
            layer(
                new LayerBuilder("Layer_ID") {
                  {
                    childLayoutVertical(); // layer properties, add more...

                    // <panel>
                    panel(
                        new PanelBuilder("Panel_ID") {
                          {
                            childLayoutCenter(); // panel properties, add more...

                            // GUI elements
                            control(
                                new ButtonBuilder("Button_ID", "Hello Nifty") {
                                  {
                                    alignCenter();
                                    valignCenter();
                                    height("5%");
                                    width("15%");
                                  }
                                });

                            // .. add more GUI elements here

                          }
                        });
                    // </panel>
                  }
                });
            // </layer>

          }
        }.build(nifty));

    // </screen>

    nifty.gotoScreen("Screen_ID"); // start the screen
  }
Beispiel #2
0
 // main display method (overwritten by subclasses) Note: disposal of previous screen already done
 // in HUD_Main class
 public void display(Nifty n) {
   // blank hud
   n.addScreen(
       "start",
       new ScreenBuilder("start") {
         {
           // blank gui screen (e.g. for cutscenes)
         }
       }.build(n));
   // show screen
   n.gotoScreen("start");
 }
  public void simpleInitApp() {
    NiftyJmeDisplay niftyDisplay =
        new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
    nifty = niftyDisplay.getNifty();
    nifty.loadStyleFile("nifty-default-styles.xml");
    nifty.loadControlFile("nifty-default-controls.xml");
    // create nifty
    nifty.registerEffect("customHint", "rpgTest.ui.test.CustomHint");

    nifty.addScreen("start", makeScreen1(nifty));
    nifty.gotoScreen("start");

    // attach the nifty display to the gui view port as a processor
    guiViewPort.addProcessor(niftyDisplay);

    // disable the fly cam
    flyCam.setEnabled(false);
  }
  @Override
  public void prepareStart(final Nifty nifty) {
    // create a screen
    Screen screen =
        new ScreenBuilder("start") {
          {
            controller(HelloNiftyBuilderExampleMain.this);

            layer(
                new LayerBuilder("layer") {
                  {
                    backgroundColor("#003f");
                    childLayoutCenter();

                    panel(
                        new PanelBuilder() {
                          {
                            id("panel");
                            childLayoutCenter();
                            height("25%");
                            width("80%");
                            alignCenter();
                            valignCenter();
                            backgroundColor("#f60f");
                            visibleToMouse();
                            interactOnClick("quit()");
                            padding("10px");

                            onStartScreenEffect(
                                new EffectBuilder("move") {
                                  {
                                    effectParameter("mode", "in");
                                    effectParameter("direction", "top");
                                    length(300);
                                    startDelay(0);
                                    inherit(true);
                                  }
                                });

                            onEndScreenEffect(
                                new EffectBuilder("move") {
                                  {
                                    effectParameter("mode", "out");
                                    effectParameter("direction", "bottom");
                                    length(300);
                                    startDelay(0);
                                    inherit(true);
                                  }
                                });

                            onHoverEffect(
                                new HoverEffectBuilder("pulsate") {
                                  {
                                    effectParameter("scaleFactor", "0.008");
                                    effectParameter("startColor", "#f600");
                                    effectParameter("endColor", "#ffff");
                                    post(true);
                                  }
                                });

                            panel(
                                new PanelBuilder() {
                                  {
                                    childLayoutHorizontal();
                                    alignCenter();
                                    valignCenter();
                                    width("100%");

                                    image(
                                        new ImageBuilder() {
                                          {
                                            filename("nifty-logo-150x150.png");
                                          }
                                        });

                                    text(
                                        new TextBuilder() {
                                          {
                                            text("Hello Nifty Builder World!!!");
                                            font("aurulent-sans-17.fnt");
                                            color("#000f");
                                            width("*");
                                            alignCenter();
                                            valignCenter();
                                          }
                                        });
                                  }
                                });
                          }
                        });
                  }
                });
          }
        }.build(nifty);

    nifty.addScreen("start", screen);
  }