Processing 特訓(xùn)(Particles) - 5

明確概念

Particle system: 里面有N個(gè)particle,進(jìn)行重復(fù)隨機(jī)的行為

fill(color, alpha): alpha范圍為0-255

ArrayList<Object>:對(duì)象數(shù)組,特性初始化時(shí)不需要確定數(shù)組長度,size()獲得當(dāng)前長度,add()添加對(duì)象,get(index)獲取對(duì)應(yīng)index對(duì)象,remove(index)移除對(duì)應(yīng)index對(duì)象

Inheritance: 繼承,聲明類,class 子類 extends 父類 {}, 類初始化,class(){ super(); }

Polymorphism: 多態(tài),多個(gè)子類都屬于父類(循環(huán)時(shí)統(tǒng)一調(diào)用),會(huì)根據(jù)子類名稱選擇調(diào)用特定同名方法


明確功能

1.多個(gè)particleSystem生態(tài)

功能設(shè)計(jì)

類:particleSystem

屬性:particles, particle, location, velocity, acceleration, lifespan

方法:move(),display(), isDead(), run()

偽代碼

setup(){

}

draw(){

? ? ps.run();

}

class Particle{

? ? 定義屬性

? ? Particle(){}

????定義方法

}

class ParticleSystems{

? ? 定義屬性

? ? ParticleSystems(){}

????定義方法

}

正式代碼

見:

Processing/Particles at master · JoeyQiang/Processing · GitHub

代碼優(yōu)化

1.N個(gè)Particle

2.Particle的繼承和多態(tài),多個(gè)形狀的Particle

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容