3
http://processing.org/learning/eclipse/根据步骤5,我在我的Main方法中使用PApplet.main(new String[] { "--present", "MyGame" });
。游戏处于全屏模式,我如何切换到窗口模式?
(我不想只是运行它的Java Applet ...)(在Eclipse中使用处理库)如何使用窗口模式?
感谢
http://processing.org/learning/eclipse/根据步骤5,我在我的Main方法中使用PApplet.main(new String[] { "--present", "MyGame" });
。游戏处于全屏模式,我如何切换到窗口模式?
(我不想只是运行它的Java Applet ...)(在Eclipse中使用处理库)如何使用窗口模式?
感谢
如果你不想使用窗口模式,只需不传递参数:
PApplet.main(new String[] {"MyGame"});
如果你想从当前模式切换到窗口模式,你需要手动处理AFAIK。 PApplet扩展了java的Applet类,并使用Frame将内容添加到。 这里有一个快速的黑客:
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()方法来获得所需的设置。
你会怎么做,即从窗口模式切换到全屏模式? – Koffiman 2014-04-24 05:29:32
@Koffiman你可以尝试像这样:'java.awt.Rectangle fs = new java.awt.Rectangle(0,0,displayWidth,displayHeight); frame.setBounds(fs); setBounds(fs);'但问题你不能让框架未修饰(无边框/关闭按钮/等)。也许你应该把这个作为一个单独的问题发布,并得到更多的答案/建议 – 2014-04-24 11:21:57
完成!你可能会发布你的答案[这里](http://stackoverflow.com/questions/23260640/java-processing-2-0-using-eclipse-switching-from-window-to-fullscreen-and-ba)来获取讨论会进行? – Koffiman 2014-04-25 01:12:43