作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Processing 创建一个多人游戏,但无法弄清楚如何将屏幕分成两个以显示玩家的不同情况?
就像在 c# 中一样,我们有Viewport leftViewport,rightViewport;
来解决问题。
非常感谢
最佳答案
在处理所有绘图操作(如 rect、eclipse 等)时,都是在 PGraphics 元素上完成的。您可以使用您选择的渲染器创建两个新的 PGraphic 对象,在它们上绘制并将它们添加到您的主 View 中:
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);
}
关于处理:如何分屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6972225/
我是一名优秀的程序员,十分优秀!