我必须将两个球形状的按钮成像,我想在相反的方向上移动球,因为它被其他球击中。当它与其他球发生碰撞时移动正常,但我想向相反方向移动球。在此先感谢
case MotionEvent.ACTION_MOVE:
view.setY(event.getRawY() + dY);
view.setX(event.getRawX() + dX);
lastAction = MotionEvent.ACTION_MOVE;
final View dragView1 = findViewById(R.id.ib1);
Rect rect=new Rect();
view.getHitRect(rect);
Rect rect1=new Rect();
dragView1.getHitRect(rect1);
if(Rect.intersects(rect,rect1)) {
TranslateAnimation animation = new TranslateAnimation(0.0f, -400.0f, 0.0f, 0.0f);
animation.setDuration(1000);
animation.setRepeatMode(0);
dragView1.startAnimation(animation);}
break;