2011-08-07 13 views
4

私はProcessingでマルチプレイヤーゲームを作成しようとしていますが、プレイヤーの異なる状況を表示するために画面を2つに分割する方法を理解できませんか?処理:画面を分割する方法は?

のように、私たちは Viewport leftViewport,rightViewport; です。日食などRECT、などのすべての描画操作を処理する際に

どうもありがとう

答えて

4

はPGraphics要素で行われます。レンダラを使用して2つの新しいPGraphicオブジェクトを作成し、描画してメインビューに追加することができます。

int w = 500; 
int h = 300; 
void setup() { 
    size(w, h); 
    leftViewport = createGraphics(w/2, h, P3D); 
    rightViewport = createGraphics(w/2, h, P3D); 
} 

void draw(){ 
    //draw something fancy on every viewports 
    leftViewport.beginDraw(); 
    leftViewport.background(102); 
    leftViewport.stroke(255); 
    leftViewport.line(40, 40, mouseX, mouseY); 
    leftViewport.endDraw(); 

    rightViewport.beginDraw(); 
    rightViewport.background(102); 
    rightViewport.stroke(255); 
    rightViewport.line(40, 40, mouseX, mouseY); 
    rightViewport.endDraw(); 

    //add the two viewports to your main panel 
    image(leftViewport, 0, 0); 
    image(rightViewport, w/2, 0); 


}