Ok, so after considering all the helpful comments people left for me, I decided to recreate it and just try it with two different images. This is my code:
Main Class:
[java]public class Main extends SimpleApplication implements ActionListener{
MainMenu mainMenu = new MainMenu();
Game game = new Game();
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
initControls();
stateManager.attach(mainMenu);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
private void initControls() {
inputManager.addMapping("Next", new KeyTrigger(KeyInput.KEY_N));
inputManager.addListener(this, "Next");
}
public void onAction(String binding, boolean isPressed, float tpf) {
if (binding.equals("Next")) {
if (isPressed) {
stateManager.detach(mainMenu);
stateManager.attach(game);
}
}
}
}[/java]
Main Menu Class:
[java]public class MainMenu extends AbstractAppState{
private SimpleApplication app;
private Node rootNode;
private Node guiNode;
private AssetManager assetManager;
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (SimpleApplication) app;
this.rootNode = this.app.getRootNode();
this.guiNode = this.app.getGuiNode();
this.assetManager = this.app.getAssetManager();
initBackground();
}
@Override
public void update(float tpf) {
}
@Override
public void cleanup() {
super.cleanup();
}
private void initBackground() {
Picture pic = new Picture("HUD Picture");
pic.setImage(assetManager, "/Interface/Splash1.png", true);
pic.setWidth(1920);
pic.setHeight(1080);
pic.setPosition(0,0);
guiNode.attachChild(pic);
}
}[/java]
Game Class:
[java]public class Game extends AbstractAppState {
private SimpleApplication app;
private Node rootNode;
private Node guiNode;
private AssetManager assetManager;
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (SimpleApplication) app;
this.rootNode = this.app.getRootNode();
this.guiNode = this.app.getGuiNode();
this.assetManager = this.app.getAssetManager();
initBackground();
}
@Override
public void update(float tpf) {
}
@Override
public void cleanup() {
super.cleanup();
}
private void initBackground() {
Picture pic = new Picture("HUD Picture");
pic.setImage(assetManager, "/Interface/Splash2.jpg", true);
pic.setWidth(1920);
pic.setHeight(1080);
pic.setPosition(0,0);
guiNode.attachChild(pic);
}
}[/java]
This seams to be working fine. When I hit the N key (I decided to change it) the image changes. Now what I donāt understand is why the same is code in not working with the actual game code.
UPDATE: So I retried doing it with the actual game code, and it does not work. So I now know that the problem is not with the way I am making my state. The problem is within the game code that I have. I am not exactly sure whats causing it.