根据第5步,我在我的Main方法中使用了
谢谢
PApplet.main( new String[] { "--present", "MyGame" });
。游戏处于全屏模式,我该如何切换到窗口模式?(我不想仅将其运行为Java Applet...)谢谢
PApplet.main( new String[] { "--present", "MyGame" });
。游戏处于全屏模式,我该如何切换到窗口模式?(我不想仅将其运行为Java Applet...)PApplet.main(new String[] {"MyGame"});
import processing.core.PApplet;
public class MyGame extends PApplet {
public void setup(){
size(400,400);
background(255);
smooth();
stroke(0,32);
}
public void draw(){
fill(255,1);
rect(0,0,width,height);
translate(width/2,height/2);
rotate(frameCount * .1f);
line(0,0,width/3,0);
}
public void keyPressed(){
if(key == 'f') exitFullscreen();
}
private void exitFullscreen() {
frame.setBounds(0,0,width,height);
setBounds((screenWidth - width) / 2,(screenHeight - height) / 2,width, height);
frame.setLocation((screenWidth - width) / 2,(screenHeight - height) / 2);
setLocation((screenWidth - width) / 2,(screenHeight - height) / 2);
}
public static void main(String args[]) {
PApplet.main(new String[] { "--present", "MyGame" });
}
}
可以随意调整 exitFullscreen() 方法以获得所需的设置。
java.awt.Rectangle fs = new java.awt.Rectangle(0, 0, displayWidth, displayHeight); frame.setBounds(fs); setBounds(fs);
但是,问题在于您无法让框架没有装饰(无边框/关闭按钮等)。也许您应该将此作为单独的问题发布,以获取更多答案/建议。 - George Profenza