Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Processing 处理:如何分割屏幕?_Processing - Fatal编程技术网

Processing 处理:如何分割屏幕?

Processing 处理:如何分割屏幕?,processing,Processing,我正在尝试创建一个具有处理功能的多人游戏,但不知道如何将屏幕一分为二以显示不同玩家的情况 就像在c#中一样,我们有 视口左视口、右视口 解决这个问题 非常感谢您处理所有绘图操作,如rect、eclipse等,都是在PGraphics元素上完成的。您可以使用自己选择的渲染器创建两个新的PGraphic对象,在其上绘制并将其添加到主视图中: int w = 500; int h = 300; void setup() { size(w, h); leftViewport = createGr

我正在尝试创建一个具有处理功能的多人游戏,但不知道如何将屏幕一分为二以显示不同玩家的情况

就像在c#中一样,我们有
视口左视口、右视口
解决这个问题


非常感谢您处理所有绘图操作,如rect、eclipse等,都是在PGraphics元素上完成的。您可以使用自己选择的渲染器创建两个新的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);


}