Processing 错误;推送矩阵的运行次数不能超过32次,则;目标VM未能初始化"; 在运行这个草图的过程中,我一直得到一个“不能运行推矩阵超过32次”。我知道这可能是一个有pushMatrix()的问题;没有匹配popMatrix()的调用;但我在代码中没有看到它。谢谢你的帮助

Processing 错误;推送矩阵的运行次数不能超过32次,则;目标VM未能初始化"; 在运行这个草图的过程中,我一直得到一个“不能运行推矩阵超过32次”。我知道这可能是一个有pushMatrix()的问题;没有匹配popMatrix()的调用;但我在代码中没有看到它。谢谢你的帮助,processing,Processing,备案;我知道这段代码不是很漂亮,可以进行广泛的重构。我还是一个编程新手,这只是一个从我开始编写代码的那天起就一直在进行的项目 再次感谢您的帮助 float x, y, d, r, g, b, t; float c = random(0, mouseY+75); float easing = 0.03; int diameter= 40; int timer= -3000; int direction = 1; float speed = .7; float angle = 0.0; float

备案;我知道这段代码不是很漂亮,可以进行广泛的重构。我还是一个编程新手,这只是一个从我开始编写代码的那天起就一直在进行的项目

再次感谢您的帮助

float x, y, d, r, g, b, t;
float c = random(0, mouseY+75);
float easing = 0.03;
int diameter= 40;
int timer= -3000;
int direction = 1;
float speed = .7;
float angle = 0.0;
float offset;
float scalar = 60;
boolean button = false;

void setup() {
size(1000, 400);
smooth();
strokeWeight(5);
}

void draw() {
  background(204);
  int currentTime = millis();
  textSize(16);
  fill (125);
  text ("Flying Circles", 20, 20);

if ((currentTime < 5000) && (mousePressed==false)){ 
    r = noise(frameCount * 0.01) * 255;                   //clockwise spin
    g = frameCount % 255;
    b = 255 - noise(1 + frameCount * 0.025) * 255;
    rectMode(CENTER);
    background(204);
    pushMatrix();
    translate(mouseX, mouseY);
    pushMatrix();
    rotate(-angle);
    ellipse(0,0, 150, 150);
    ellipse(0,0, 125, 125);
    rect(0,0, 80, 80);
    popMatrix();
    pushMatrix();
    rotate(angle);
    rect(0, 0, 80, 80);
    rect(0, 0, 60, 60);
    popMatrix();
    pushMatrix();
    rotate(-angle);
    fill(r,g,b);
    rect(-270, 0, 80, 80);
    rect(270, 0, 80, 80);
    rect(0, 0, 40, 40);
    angle += 0.1;
    popMatrix();
    popMatrix();

}else{
       drawCounterspin();
}
}


void keyPressed() {
      button = !button;
    }

void drawFighter(){
    float targetX = mouseX;
    float d = random(0, 150);
    x += (targetX - x) * easing*1.5;
    fill(mouseY, mouseY/2, mouseY/3);
    ellipse(x-300, mouseY, 100, 100);
    fill(d, d*1.2, d*1.5);
    ellipse(x, mouseY, 80, 80);
    fill(mouseY, mouseY/2, mouseY/3);
    ellipse(x+300, mouseY, 100, 100);
    line(x+40, mouseY,x+250, mouseY);
    line(x-40, mouseY,x-250, mouseY);
    fill(d, d, d);
    ellipse(x, mouseY+100, 80, 80);
    fill(d, d, d);
    ellipse(x, mouseY+200, 60,60);
    line(x+30,mouseY+30, width, mouseY*2);
    line(x-30,mouseY+30, 0, mouseY*2);
}

void drawOilbounce() {
       x = width/2;
       y += speed * direction;
       if ((y > height/2+diameter) || (y < 0)) {
         direction = -direction;
         scalar = -scalar;
       }
       float spinspeed = speed * .1;
       float spinx = x+ cos(angle) * scalar;
       float spiny = y+ sin(angle) * scalar;
       angle += spinspeed;
       scalar += spinspeed; 
      scalar = constrain(scalar, 30, 300);
      fill(r,g,b);
      ellipse(spinx, spiny, 30, 30);
      fill(r*.95, g*.85, b*.75);
      ellipse(x, y, diameter, diameter);
      fill(r*.85, g*.75, b*.65);
      ellipse(x, y*1.2, y*.02*diameter, diameter);
      fill(r*.75, g*.65, b*.55);
      ellipse(x, y*1.5, y*.05*diameter, diameter);
    }

void drawCounterspin(){
  pushMatrix();                              
  rectMode(CENTER);             
  mouseX = constrain (mouseX, 250, width-250);
  mouseY = constrain (mouseY, 48, height-48);
  fill(mouseY, 80, 100);
  if (mouseButton == LEFT) {
  translate(mouseX, mouseY);
  scale(sin(angle));
  rotate(angle);
  ellipse(0,0, 150, 150);
  ellipse(0,0, 125, 125);
  fill(mouseY, mouseX/2, mouseX);
  rect(0, 0, 80, 80);
  fill(mouseY/2, mouseX/3, mouseX);
  rect(250, 0, 80, 80);
  fill(mouseY, mouseX, mouseX/2);
  rect(-250, 0, 80, 80);
  angle += 0.05;
  popMatrix();
  }
  }
浮点x,y,d,r,g,b,t;
浮动c=随机(0,鼠标+75);
浮动利率=0.03;
内径=40;
int定时器=-3000;
int方向=1;
浮动速度=.7;
浮动角度=0.0;
浮动偏移量;
浮点标量=60;
布尔按钮=假;
无效设置(){
大小(1000、400);
光滑的();
冲程重量(5);
}
作废提款(){
背景(204);
int currentTime=millis();
文本大小(16);
填充(125);
文本(“飞行圈”,20、20);
如果((currentTime<5000)&&(mousePressed==false)){
r=噪波(帧数*0.01)*255;//顺时针旋转
g=帧数%255;
b=255-噪声(1+帧数*0.025)*255;
矩形模式(中心);
背景(204);
pushMatrix();
翻译(mouseX,mouseY);
pushMatrix();
旋转(-角度);
椭圆(0,0,150,150);
椭圆(0,0,125,125);
rect(0,0,80,80);
popMatrix();
pushMatrix();
旋转(角度);
rect(0,0,80,80);
rect(0,0,60,60);
popMatrix();
pushMatrix();
旋转(-角度);
填充物(r、g、b);
rect(-270,0,80,80);
rect(270,0,80,80);
rect(0,0,40,40);
角度+=0.1;
popMatrix();
popMatrix();
}否则{
牵引销();
}
}
按下void键(){
按钮=!按钮;
}
虚空战斗机(){
浮动目标x=鼠标;
浮动d=随机(0,150);
x+=(targetX-x)*宽松*1.5;
填充(鼠塞,鼠塞/2,鼠塞/3);
椭圆(x-300,鼠标,100100);
填充(d,d*1.2,d*1.5);
椭圆(x,mouseY,80,80);
填充(鼠塞,鼠塞/2,鼠塞/3);
椭圆(x+300,鼠标,100100);
线(x+40,鼠标,x+250,鼠标);
线路(x-40,鼠标,x-250,鼠标);
填充(d,d,d);
椭圆(x,鼠标+100,80,80);
填充(d,d,d);
椭圆(x,鼠标+200,60,60);
线(x+30,鼠标+30,宽度,鼠标*2);
线(x-30,鼠标+30,0,鼠标*2);
}
void drawOilbounce(){
x=宽度/2;
y+=速度*方向;
如果((y>高度/2+直径)| |(y<0)){
方向=-方向;
标量=-标量;
}
浮动转速=转速*.1;
float spinx=x+cos(角度)*标量;
浮点数y=y+sin(角度)*标量;
角度+=旋转速度;
标量+=自旋速度;
标量=约束(标量,30,300);
填充物(r、g、b);
椭圆(spinx,spiny,30,30);
填充物(r*.95、g*.85、b*.75);
椭圆(x,y,直径,直径);
填充物(r*.85、g*.75、b*.65);
椭圆(x,y*1.2,y*.0.02*直径,直径);
填充物(r*.75、g*.65、b*.55);
椭圆(x,y*1.5,y*.0.05*直径,直径);
}
空抽反销(){
pushMatrix();
矩形模式(中心);
mouseX=约束(mouseX,250,宽度-250);
mouseY=约束(mouseY,48,高度-48);
填充(老鼠,80,100);
如果(鼠标按钮==左){
翻译(mouseX,mouseY);
标度(sin(角));
旋转(角度);
椭圆(0,0,150,150);
椭圆(0,0,125,125);
填充(mouseY,mouseX/2,mouseX);
rect(0,0,80,80);
填充(mouseY/2、mouseX/3、mouseX);
rect(250,0,80,80);
填充(mouseY、mouseX、mouseX/2);
rect(-250,0,80,80);
角度+=0.05;
popMatrix();
}
}

摆脱函数中的两个调用(push和pop)
drawCounterspin()
以解决问题而不产生副作用。但我真的不知道为什么。。。在使用函数内部的push/popMatrix之前,我已经意识到了这种行为。如果需要,隔离draw中的调用,而不是函数中的调用,如:

pushMatrix();
drawCounterspin();
popMatrix();
以前为我工作过