(在Eclipse中使用处理库)如何使用窗口模式? [英] (using processing library in Eclipse) how do I use window mode?

查看:192
本文介绍了(在Eclipse中使用处理库)如何使用窗口模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://processing.org/learning/eclipse/ 根据第5步,我用我的Main方法中的PApplet.main(new String [] { - present,MyGame}); 。游戏处于全屏模式,如何切换到窗口模式?

(我不想将它作为Java Applet运行...)

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...)

谢谢

推荐答案

如果您不想使用窗口模式,只需不要传递参数:

If you don't want to use window mode, simply don't pass the argument:

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

如果你想从现在模式切换到窗口模式,你需要手动处理AFAIK 。 PApplet扩展了java的 Applet 类并使用框架将内容添加到。
这是一个快速破解:

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" });
    }
}

使用exitFullscreen()方法进行免费修补所需的设置。

Feel free tinker with the exitFullscreen() method to get the desired setup.

这篇关于(在Eclipse中使用处理库)如何使用窗口模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆