boolean和mousePress问题求助
processing吧
全部回复
仅看楼主
level 2
经济刺猬 楼主
想让小球到达右边之后能返回,但是不知道怎么写。
2018年10月02日 02点10分 1
level 2
经济刺猬 楼主
nt x =100;
boolean btGo=false;
boolean btBack=false;
void setup(){
size (400, 300);
}
void draw (){
background (0);
fill (255);
noStroke();
ellipse(x, height/2, 30, 30);
if((btBack)&&(x>width)){
x=x-1;
}
else if((btGo)&&(x<width)){
x=x+1;
}
}
void mousePressed(){
if(x>width){
btBack=!btBack;
}
else if(x<width){
btGo=!btGo;
}
}
2018年10月02日 02点10分 2
level 11
int x =-1;
boolean bool =true;
void setup(){
size(400,300);
}
void draw(){
background(0);
fill(255);
noStroke();
ellipse(x,150,20,20);
if(x>=0){
if(bool){
x+=10;
}else if(!mousePressed){
x-=10;
}if((x==0)||(x==width)){
bool=!bool;
}
}
}
void mousePressed(){
x=0;
}
2018年10月12日 03点10分 4
1