(using the processing library in Eclipse) how to use windowed mode?

http://processing.org/learning/eclipse/ according to 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 a Java applet ...)

thanks

+3
source share
1 answer

If you do not want to use windowed mode, just do not pass an argument:

 PApplet.main(new String[] {"MyGame"}); 

If you want to switch from current mode to window mode, you will need to manually handle AFAIK. PApplet extends the java Applet class and uses Frame to add content to. Here is 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 to bother with the exitFullscreen () method to get the setting you need.

+3
source

Source: https://habr.com/ru/post/1236527/


All Articles