mouseWheel 的处理变量

Processing variable for mouseWheel

JavaProcessing Java中是否有存储鼠标是否滚动的变量?我知道 Processing 中有一个 function 但我需要一个 variable.

您必须创建自己的变量并将其设置在 mouseWheel 函数中。

float wheelCount = 0;

void setup() {
  size(100, 100);
}

void draw() {
   if(wheelCount > 0){
      //do something with the variable

      wheelCount = 0; //reset it so we don't keep getting events
   }

} 

void mouseWheel(MouseEvent event) {
  wheelCount = event.getCount();
}

但是,请注意 wheelCount 变量仅对单个帧有效,这就是为什么您应该改用事件。