Object

本参考资料用于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.

名称

Object

示例
 // Declare and construct two objects (h1, h2) from the class HLine  HLine h1 = new HLine(20, 2.0);

HLine h2 = new HLine(50, 2.5);




void setup()
 {  
size(200, 200);


frameRate(30);


  } 
void draw()
{  
 background(204);



h1.update();


 
h2.update();


  }  
  class HLine{  
float ypos, speed;

 
 HLine (float y,float s)
{
 ypos = y;


speed = s;

 
 }   
void update()
{
ypos += speed;


if (ypos > width)
{
  ypos = 0;


  }      line(0, ypos, width, ypos);



  } 
  }  
描述 Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants).
语法
 ClassName instanceName 
参数
ClassName the class from which to create the new object
instanceName the name for the new object
相关 class

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

Object