yes,
i figured out the problem:
here is my latest code:
-------------------------------------
//a very simple delay movement
mousesquare ms1,ms2,ms3,ms4;
void setup(){
size(400,400);
rectMode(CENTER);
fill(120);
noStroke();
framerate(60);
ms1=new mousesquare(100,100);
ms2=new mousesquare(100,100);
ms3=new mousesquare(100,100);
ms4=new mousesquare(100,100);
}
//for loop,
void draw(){
background(200);
ms1.display();
ms2.display();
ms3.display();
ms4.display();
ms1.moveto(mouseX,mouseY,2);
ms2.moveto(mouseX,mouseY,5);
ms3.moveto(mouseX,mouseY,10);
ms4.moveto(mouseX,mouseY,20);
}
class mousesquare{
float xpos;
float ypos;
mousesquare(float xx,float yy){
xpos=xx;
ypos=yy;
}
void moveto(float tarX,float tarY,int friction){
float difx=tarX-xpos;
if(abs(difx)>1.0){
xpos +=difx/friction;
}
float dify=tarY-ypos;
if(abs(dify)>1.0){
ypos +=dify/friction;
}
}
void display(){
rect(xpos,ypos,30,30);
}
}
-------------------------
the mistake is i void the display() outside of the object class, that is why the xpos and ypos is not defined so that cannot be access.
ok, good lesson finally. thanks to mflux for enlightening
sooon