經過一段時間的摸索processing,感覺有一點頭緒了。但是processing用起來確實比較吃力。
因爲有很多事件不像U3D或者as3那麼方面,就簡單的鼠標事件,碰撞,這些功能有很多processing
自身就很薄弱了。經過自己的多次的嘗試,希望自己做的小案例可以跟一些入門的朋友一起分享
processing鼠標移動物體停止旋轉,鼠標離開物體繼續旋轉
float xs,ys;
float angle=0;
boolean sbolean=true;
float rSphere=100;
void setup(){
size(500,500,P3D);
}
void draw(){
update(mouseX,mouseY);
background(255);
xs=width/2;
ys=height/2;
translate(xs,ys,0);
rotateX(angle);
rotateY(angle);
if(sbolean){
angle=angle+0.02;
}
sphereDetail(15,15);
sphere(rSphere);
}
void mousePressed(){
sbolean=!sbolean;
}
void update(float x,float y){
if(x>=xs&&x<=xs+rSphere/2 || y>=ys && y<= ys+rSphere/2){
fill(#dd0000);
sbolean=false;
}else{
noFill();
sbolean=true;
}
}