i have this code and i would like the object to slow down smoothly in the invisible box (coded box) but the object slows down to quickly, so how could i make it slow down smoothly:?
if(obj==objective.right) { if((getX()>=(title.getWidth()/2)-60)&&(getX()<=(title.getWidth()/2)+30)){ if((speed>1)){ speed=speed-1; //System.out.print(speed); } }else{ if(ti1==1){ speed= speed +1; ti1=0; }else{ ti1++; } } }else { //System.out.print("error: "+obj); } mov= mov+speed; if(obj==objective.right){ setLocation(0+mov,title.getHeight()/2); }else if(obj==objective.left){ setLocation(title.getWidth()-mov,title.getHeight()/2); }else { System.out.print("error: "+obj); }