Hello Nifty 1.3 [New Tutorial]

iamcreasy said:
4. XML : This part of code might contains error. a quick check and found the panels are messed up.

I found out why, you had one flipped ChildLayout, and the width/height for one element was within the wrong block. But that's fixed now, and I copied the code to the Nifty Java tutorial on the wiki! Good team work.

Adding the actual controls (except button) are still TODO.

I added the controls, too!



Man, writing this example was the first time that anything in Nifty GUI was easy. I’m probably dreaming. :wink: Thanks @iamcreasy!



Now on to the last part…

1 Like
zathras said:
I added the controls, too!


Amazing! The whole No-Nifty-Doc nightmare for everyone is the forum will be over soon. :)

I am also writing a framework to handle a basic game mechanism. I am terrible programmer, but trying to come up with something for my game. I am following this instructions, under topic Extend SimpleApplication from, https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:best_practices The basic part of the framework is almost complete. Now user has to create a new level ( new class that extends RFPSimpleLevel) and just copy and paste Hello X tutorial code, without the main function. But, I am not sure if the framework setup is correct. It would be nice if you can check it out. :) I am gonna update the framework in google project withing the next couple of hours. Link on the next post.

Dunno if you have noticed,@wezrule has createda tutorial today on loading screen. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:loading_screen :D

Update : SVN connection is causing issues, it might take some time.

I ve found big design flaw. Will post it later.

Hi @iamcreasy,



I’m about as far as you are, not Java expert either, but learning. Good idea to include a video, I think you are using AppStates right. I was confused for a moment because you testlevel and newlevel Java class names look like methods, if you capitalize class names then it’s clearer for the viewer to see what is what.



One thing made me wonder: In the AppState’s update loop, you use …rootNode.updateGeometricState();… etc – Can you try the following instead?

You already got an Application app object from the initialize() method. Can you cast it to SimpleApplication and try app.getRootNode().attachChild(rootNode); ? That would attach your AppState’s internal rootNode to the main rootNode – and then the SimpleApplication would automaticlaly handle updating everything attached, and you wouldn’t need to do that yourself.

Also the same holds for the guiNode. Maybe there is a parallel solution for the rendering part too?

hey, exactly that’s what I was mentioning. I am rewriting them from the scratch, the current one in the repository is not meaningful anymore. I have had posted what the (10-12 hour ago) my code looked like.





MAIN[java]

public class Main extends SimpleApplication{



MainMenuState mainMenuState;



public static void main(String[] args){

Main app = new Main();

app.start();

}



public void simpleInitApp() {

fixSimpleApp();



mainMenuState = new MainMenuState(this);



stateManager.attach(mainMenuState);

}



public void fixSimpleApp(){

inputManager.deleteMapping(INPUT_MAPPING_EXIT);

}

}

[/java]



state class :

[java]public class MainMenuState extends AbstractAppState implements ScreenController{



SimpleApplication game = null;

private NiftyJmeDisplay niftyDisplay = null;

private Nifty nifty = null;



public MainMenuState(SimpleApplication game) {

this.game = game;

}



@Override

public void initialize(AppStateManager stateManager, Application app) {

super.initialize(stateManager, app);



niftyDisplay = new NiftyJmeDisplay(game.getAssetManager(),

game.getInputManager(),

game.getAudioRenderer(),

game.getGuiViewPort());

nifty = niftyDisplay.getNifty();



nifty.fromXml(“Interface/intro.xml”, “start”, this);



game.getGuiViewPort().addProcessor(niftyDisplay);

game.getInputManager().setCursorVisible(true);

}



@Override

public void stateAttached(AppStateManager stateManager) {

}



@Override

public void stateDetached(AppStateManager stateManager) {

game.getGuiViewPort().removeProcessor(niftyDisplay);

game.getStateManager().attach(new InGameState(game));

}



@Override

public void update(float tpf) {

super.update(tpf);

if (nifty.getScreen(“start”) == null) game.getStateManager().detach(this);

}



public void bind(Nifty nifty, Screen screen) {

}



public void onStartScreen() {

}



public void onEndScreen() {

}



public void startGame(){

nifty.removeScreen(“start”);

}



public void exitGame(){

game.stop();

}

}

[/java]



after this a lot have been improved. written some builder classes. so, you can add asset in your scene with less code, Like to add a model from, “Models/rabbit/rabbit.j3o”, and adding a string as user data, attaching it to the root and scaling them, all the done by the following line. [Builder Pattern]



[java]Node rabbit = new EntityBuilder()

.assetName(“rabbit”)

.assetUserData(“player”)

.parentNode(game.getRootNode())

.localScale(0.25f)

.initNodeBuilder().getNode(); [/java]