我正在关注Youtube上的thenewboston关于Java游戏开发的一系列教程。我正处于可以制作全屏窗口的位置,但分辨率拒绝调整为800x600。我测试了vc,一个GraphicsEnvironment.getDefaultScreenDevice对象,以及dm,一个DisplayMode,它们似乎不是问题所在。我正在运行Snow Leopard。有什么想法吗?
if(dm != null && vc.isDisplayChangeSupported()){
try{
vc.setDisplayMode(dm);
System.out.println("Display mode set");
}catch(Exception ex){System.out.println("Despite the vc saying it is display change supported and the DM is not null, something went wrong");}
}
}
答案 0 :(得分:1)
将此代码添加到Core.java(或GameClient.java)类中。问题可能是您没有将所需的DM [] args传递给ScreenManager.java类。
private static final DisplayMode modes[] = { //common monitor DMs
new DisplayMode(1366,768,32, DisplayMode.REFRESH_RATE_UNKNOWN), //1366x768px w/32-bit depth
new DisplayMode(1366,768,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(1366,768,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
new DisplayMode(800,600,32, DisplayMode.REFRESH_RATE_UNKNOWN), //800x600px w/32-bit depth
new DisplayMode(800,600,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(800,600,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
new DisplayMode(640,480,32, DisplayMode.REFRESH_RATE_UNKNOWN), //640x480px w/32-bit depth
new DisplayMode(640,480,24, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/24-bit depth
new DisplayMode(640,480,16, DisplayMode.REFRESH_RATE_UNKNOWN), // ' w/16-bit depth
};
我假设错误与您的public void setFullScreen(DisplayMode dm)方法有关。在这种情况下,此方法的完整语法是:
/*****************************************************************************
* @description: Creates window for program to run in, using appropriate DM
* @param DisplayMode dm
*/
public void setFullScreen(DisplayMode dm){
JFrame f = new JFrame();
f.setUndecorated(true); //no titlebars/scroll bars etc.
f.setIgnoreRepaint(true);
f.setResizable(false); //user cannot resize window
vc.setFullScreenWindow(f);
if(dm!=null && vc.isDisplayChangeSupported()){ //if DM is changeable
try {
vc.setDisplayMode(dm);
} catch (Exception e){/*Catch 'em all*/}
}
f.createBufferStrategy(2); //set # of screen buffers to 2
}//setFullScreen()
在发布之后注意到这是一个温和的死灵帖子。 Aaahh ...