JMonkeyEngine全屏脚本

时间:2014-01-13 09:09:41

标签: fullscreen

我是Java脚本的新手我想知道你们中是否有人能告诉我这些行有什么问题:

GraphicsDevice device = GraphicsEnviroment.
     getLocalGraphicEnviroment().getDefaultScreenDevice();
settings.setResolution(modes[0].getWidth(), modes][0].getHeight());
settings.setFrequency(mdoe{[0].getFrequencyRate());
settings.setDepthBits(modes[0].getBitDepth());
settings.setFullscreen(device.isFullScreenSupported());

1 个答案:

答案 0 :(得分:0)

我确信我们可以辩论“脚本”一词的含义,但那是Java,而不是Java脚本(当然不是javascript)......

您有多个额外标点符号,缺少变量声明和拼写错误的方法名称的问题。您可以在jME3 website上找到您想要的代码:

public void toggleToFullscreen() {
  GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  DisplayMode[] modes = device.getDisplayModes();
  int i=0; // note: there are usually several, let's pick the first
  settings.setResolution(modes[i].getWidth(),modes[i].getHeight());
  settings.setFrequency(modes[i].getRefreshRate());
  settings.setBitsPerPixel(modes[i].getBitDepth());
  settings.setFullscreen(device.isFullScreenSupported());
  app.setSettings(settings);
  app.restart(); // restart the context to apply changes
}