Getting Started with jMonkey

Hello Everybody,



first off all, i’m glad to be a part of this Community. I was searching the internet for Java Engines and found this great stuff so i decided to try it. I was working the Tutorial and ok i think i understand it a little bit. My First try was to great a GameState and simply show a Nifty button, for just click to end the game, making simple and small steps :).



I’m working with c++ for 2 years now and i think i will give Java a chance and i like it, it is not to hard to learn. So my Question is now, how i have to start with the Engine ? I Just want to create a Gamestate and make this Button.



This is my first try, but i was not able to set up Niffty because i dont find the import path for the stuff i need to create an object off it.

[java]package mygame;



import mygame.GameState.Game_Load;



import com.jme3.app.SimpleApplication;

import com.jme3.system.AppSettings;



public class Main extends SimpleApplication {



static Main app;

public static void main(String[] args) {



app = new Main();



AppSettings settings = new AppSettings(true);



settings.setHeight(600);

settings.setWidth(800);

settings.setBitsPerPixel(32);

app.setSettings(settings);

app.setShowSettings(false);

app.start();





}



public void GameInit()

{

guiNode.detachAllChildren();

Game_Load gload = new Game_Load(this);

gload.init();

stateManager.attach(gload);







}



public void simpleInitApp() {



GameInit();





}



public void simpleUpdate()

{

stateManager.update(speed);

}



}

[/java]



And the GameState class:



[java]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.

    */

    package mygame.GameState;



    import com.jme3.app.state.AbstractAppState;

    import com.jme3.font.BitmapText;

    import com.jme3.font.BitmapFont;



    import mygame.Main;





    public class Game_Load extends AbstractAppState{



    private Main m_Engine;

    BitmapFont guiFont;

    BitmapText helloText;

    float in = 0;



    public Game_Load (Main i_m_Engine)

    {

    m_Engine = i_m_Engine;



    }



    public void init()

    {

    //BitmapText helloText = new BitmapText(m_Engine.getAssetManager().loadFont(“Interface/Fonts/Default.fnt”);

    guiFont = m_Engine.getAssetManager().loadFont(“Interface/Fonts/Default.fnt”);

    helloText = new BitmapText(guiFont, false);

    helloText.setSize(guiFont.getCharSet().getRenderedSize());

    helloText.setText(“Hello World”);

    helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);

    m_Engine.getGuiNode().attachChild(helloText);

    }



    @Override

    public void update(float tpf)

    {





    }

    }

    [/java]



    ok the Engine start and the Game is up, Hello world is in the Text. And now ? how i’m able to create a gui ? How i’m able to switch the Gamestate ? I really need help. How i’m able to setup new KeyBinding ?

    i hope somebody could help me

I suggest going through the tutorials top to bottom to get accustomed to the jme basics like input etc:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3#tutorials_for_beginners

Then theres more detailed info about AppStates and Controls further below.