delay()

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

名称

delay()

示例
 import processing.serial.*;

 Serial myPort;

 // The serial port 

void setup()
{  
printArray(Serial.list());


myPort = new Serial(this, Serial.list()[0], 9600);


  } 
void draw()
{  
while (myPort.available() > 0)
{
 int inByte = myPort.read();


println(inByte);


  }  
  delay(100);


  } 
描述 The delay() function halts for a specified time. Delay times are specified in thousandths of a second. For example, running delay(3000) will stop the program for three seconds and delay(500) will stop the program for a half-second.

The screen only updates when the end of draw() is reached, so delay() cannot be used to slow down drawing. For instance, you cannot use delay() to control the timing of an animation.

The delay() function should only be used for pausing scripts (i.e. a script that needs to pause a few seconds before attempting a download, or a sketch that needs to wait a few milliseconds before reading from the serial port.)

语法
  delay(napTime)
参数
napTime int: milliseconds to pause before running draw() again
返回值 void
相关 frameRate
draw()

Updated on October 2, 2018 05:02:05pm EDT

  delay()