使用ProcessingJS,我有一个确定要提供给另一个函数的数字的函数:

int number;
int theNumbers() {
  // calculations for number

  int number = 10; // sample number
  return number;
}

void mousePressed() {
  // calculations for aLongNumber

  // pass theNumbers() number value
  theNumbers();
  long numberLong = aLongNumber + (number * aLongNumber);
}


由于某种原因,现在numberLong = aLongNumber并且不加(number * aLongNumber),因为在调用theNumbers()之后,数字尚未传递给mousePressed();

最佳答案

尝试此操作,看看是否获得所需的结果:

int number = 0;
int theNumbers() {

number = 10; // sample number
return number;
}

void mousePressed() {
number = theNumbers();
long numberLong = aLongNumber + (number * aLongNumber);
}

10-06 09:41