Reputation: 936
http://processing.org/learning/eclipse/ according step 5, I used PApplet.main( new String[] { "--present", "MyGame" });
in my Main method. The game is in full screen mode, how do I switch to window mode?
(I don't want to just run it as Java Applet...)
Thanks
Upvotes: 3
Views: 2861
Reputation: 51837
If you don't want to use window mode, simply don't pass the argument:
PApplet.main(new String[] {"MyGame"});
If you want to switch from present mode to window mode, you'll need to handle things manually AFAIK. PApplet extends java's Applet class and uses a Frame to add contents into. Here's a quick hack:
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" });
}
}
Feel free tinker with the exitFullscreen() method to get the desired setup.
Upvotes: 3