2012-01-17 2 views
3

http://processing.org/learning/eclipse/手順5に従って、私はメインメソッドでPApplet.main(new String[] { "--present", "MyGame" });を使用しました。ゲームはフルスクリーンモードですが、どのようにウィンドウモードに切り替えるのですか?
(私はJavaアプレットとして実行する必要はありません...)(Eclipseの処理ライブラリを使用)ウィンドウモードはどのように使用しますか?

おかげ

答えて

3

あなたは、単に引数を渡すことはありません、ウィンドウモードを使用しない場合:

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()メソッドで自由にいじくりを感じる: は、ここでは簡単ハックです。

+0

あなたはどのようにして他の方法、つまりウィンドウモードからフルスクリーンモードに切り替えるのですか? – Koffiman

+1

@Koffiman次のようなことを試すことができます: 'java.awt.Rectangle fs = new java.awt.Rectangle(0,0、displayWidth、displayHeight); frame.setBounds(fs); setBounds(fs); 'しかし、問題はフレームをデコレートすることができません(枠線/閉じるボタンなどはありません)。おそらく、これを別の質問として投稿し、より多くの回答/提案を得るべきです。 –

+0

完了!あなたはおそらくあなたの答えをここに投稿できますか(http://stackoverflow.com/questions/23260640/java-processing-2-0-using-eclipse-switching-from-window-to-fullscreen-and-ba)ディスカッションに行く? – Koffiman

関連する問題