I’m allowing my game to be resized when in windowed mode. However, to prevent DivisonByZero errors when resizing the GUI, I’m limiting the game’s window to a minimum 640x480 window. Well, the only way I found to make it work was to check for that when resizing and if it was slower than MIN_WIDTH and/or MIN_HEIGHT, reset the settings with the minimum resolution.
(This is a method from a new SceneProcessor to detect changes in viewPort’s size)
public void reshape(ViewPort vp, int i, int i1) {
// Prevents divison by zero exceptions on GUI calculations due
// to too small resolution
if(i < Fields.MIN_WIDTH || i1 < Fields.MIN_HEIGHT) {
AppSettings settings = new AppSettings(true);
settings.setResolution(Fields.MIN_WIDTH, Fields.MIN_HEIGHT);
settings.setResizable(true);
i = Fields.MIN_WIDTH;
i1 = Fields.MIN_HEIGHT;
GameplayAppState.this.app.setSettings(settings);
GameplayAppState.this.app.restart();
}
for(ScreenResize object : screenInterfaces) {
object.onScreenResize(i, i1);
}
}
So this works well for me. On Linux. (Ubuntu 16.04)
For some reason, it’s not working on Windows. When it resets the settings, it makes the windows unresizable:
I have no clue why does this happen. I’m using jME3.1-stable.
Can you guys help me?