I've set up a basic copy of TestLoadingGameState, but when I run it, two things happen: first, the window is just black. Second, when I try to close it, it says "Program not responding" or something of the like. Can anyone explain why?
Here is my code, if you need it:
package classes;
import java.util.logging.Level;
import com.jme.app.BaseGame;
import com.jme.input.KeyInput;
import com.jme.input.MouseInput;
import com.jme.input.joystick.JoystickInput;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.LoggingSystem;
import com.jmex.game.state.GameState;
import com.jmex.game.state.GameStateManager;
import com.jme.util.Timer;
import com.jmex.game.state.load.LoadingGameState;
public class WhoNeedsWindows extends BaseGame {
public static BaseGame instance = new WhoNeedsWindows();
private Timer timer;
private float tpf;
//private InputHandler input;
public static void main(String[] args) {
//Create the GameStateManager
GameStateManager.create();
instance.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, WhoNeedsWindows.class.getResource("GibiSmall.jpg"));
instance.start();
}
public static void exit(){
instance.finish();
}
protected void cleanup() {
LoggingSystem.getLogger().log(Level.INFO, "Cleaning up resources.");
// Performs cleanup on all loaded game states.
GameStateManager.getInstance().cleanup();
KeyInput.destroyIfInitalized();
MouseInput.destroyIfInitalized();
JoystickInput.destroyIfInitalized();
}
protected void initGame() {
display.setTitle("Who Needs Windows? - The Only Game with Homicidal Penguins!");
[color=Red] // Create LoadingGameState and enable
LoadingGameState loading = new LoadingGameState();
GameStateManager.getInstance().attachChild(loading);
loading.setActive(true);
// Start our slow loading test
String status = "Started Loading";
for (int i = 0; i <= 100; i++) {
if (i == 100) {
status = "I'm Finished!";
} else if (i > 80) {
status = "Almost There!";
} else if (i > 70) {
status = "Loading Something Extremely Useful";
} else if (i > 50) {
status = "More Than Half-Way There!";
} else if (i > 20) {
status = "Loading Something That You Probably Won't Care About";
}
try{
Thread.sleep(100);
}catch(Exception e){}
loading.setProgress((float)i / 100.0f, status);
}[/color]
}
protected void initSystem() {
try {
/** Get a DisplaySystem acording to the renderer selected in the startup box. */
display = DisplaySystem.getDisplaySystem(properties.getRenderer());
/** Create a window with the startup box's information. */
display.createWindow(
properties.getWidth(),
properties.getHeight(),
properties.getDepth(),
properties.getFreq(),
properties.getFullscreen());
/** Create a camera specific to the DisplaySystem that works with
* the display's width and height*/
}
catch (JmeException e) {
/** If the displaysystem can't be initialized correctly, exit instantly. */
e.printStackTrace();
System.exit(1);
}
/** Get a high resolution timer for FPS updates. */
timer = Timer.getTimer();
}
@Override
protected void reinit() {
// TODO Auto-generated method stub
}
protected void render(float interpolation) {
// Clears the previously rendered information.
display.getRenderer().clearBuffers();
// Render the current game state.
GameStateManager.getInstance().render(tpf);
}
protected void update(float interpolation) {
// Recalculate the framerate.
timer.update();
tpf = timer.getTimePerFrame();
// Update the current game state.
GameStateManager.getInstance().update(tpf);
}
}