public void startani(int fir, int last, final Point point){
ValueAnimator animator = ValueAnimator.ofInt(fir,last);
animator.setDuration((last-fir)*100);
animator.setRepeatCount(0);
// animator.setRepeatMode(ValueAnimator.r);
animator.setInterpolator(new LinearInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int by = (int) animation.getAnimatedValue();
point.y=by;
invalidate();
}
});
animator.start();
}
public boolean onTouchEvent(MotionEvent event) {
if(misgameover){
return false;
}
int action=event.getAction();
if(action==MotionEvent.ACTION_UP){
float x=event.getX();
float y=event.getY();
Point p = getvalidpoint(x,y);
if(Mblackarray.contains§||mwhitearray.contains§)return false;
int i;
int n=p.x;
int m=p.y;
for ( i = p.y; i <=8 ; i++) {
p.set(n,i);
if(mwhitearray.contains§||Mblackarray.contains§){
break;
}else{
p.y=i;
}
}
p.y=i-1;
if(miswhite){
mwhitearray.add§;
wuziqipanel.this.setClickable(false);
startani(m,p.y,p);
wuziqipanel.this.setClickable(true);
miswhite=!miswhite;
}else{
Mblackarray.add§;
wuziqipanel.this.setClickable(false);
startani(m,p.y,p);
wuziqipanel.this.setClickable(true);
miswhite=!miswhite;
}
invalidate();
}
return true;
}
private Point getval