Processing, . (dot)
用法介紹。
用法
object.method()
object.data
參數
object
要訪問的對象method()
封裝在對象中的方法data
封裝在對象中的變量或常量
說明
提供對對象的方法和數據的訪問。對象是類的一個實例,可以包含方法(對象函數)和數據(對象變量和常量),如類定義中所指定。點運算符將程序定向到封裝在對象中的信息。
例子
// Declare and construct two objects (h1 and h2) of the class HLine
HLine h1 = new HLine(20, 1.0);
HLine h2 = new HLine(50, 5.0);
void setup() {
size(200, 200);
}
void draw() {
if (h2.speed > 1.0) { // Dot syntax can be used to get a value
h2.speed -= 0.01; // or set a value.
}
h1.update(); // Calls the h1 object's update() function
h2.update(); // Calls the h2 object's update() function
}
class HLine { // Class definition
float ypos, speed; // Data
HLine (float y, float s) { // Object constructor
ypos = y;
speed = s;
}
void update() { // Update method
ypos += speed;
if (ypos > width) {
ypos = 0;
}
line(0, ypos, width, ypos);
}
}
有關的
相關用法
- Processing FFT用法及代碼示例
- Processing SawOsc.pan()用法及代碼示例
- Processing FloatDict用法及代碼示例
- Processing FFT.stop()用法及代碼示例
- Processing join()用法及代碼示例
- Processing () (parentheses)用法及代碼示例
- Processing Pulse用法及代碼示例
- Processing PShader用法及代碼示例
- Processing PVector.set()用法及代碼示例
- Processing FloatDict.sortKeysReverse()用法及代碼示例
- Processing texture()用法及代碼示例
- Processing IntDict.add()用法及代碼示例
- Processing PShape.enableStyle()用法及代碼示例
- Processing FloatDict.sub()用法及代碼示例
- Processing String用法及代碼示例
- Processing PImage.pixels[]用法及代碼示例
- Processing vertex()用法及代碼示例
- Processing PVector.mag()用法及代碼示例
- Processing thread()用法及代碼示例
- Processing Capture.stop()用法及代碼示例
- Processing Env.play()用法及代碼示例
- Processing StringList用法及代碼示例
- Processing parseJSONArray()用法及代碼示例
- Processing JSONArray.getIntArray()用法及代碼示例
- Processing Sound.inputDevice()用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 . (dot)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。