Вопрос по Android программированию!
Здравствуйте. Я на этом форуме новенький. Это мое первое сообщение, так что если формат формулировки не совсем правильный, попрошу меня извинить. Так вот суть проблемы: У меня есть два прямоугольника я хочу одним толкать другой, но проблема в следующем... толкать-то он толкает, только вот помимо толкания он также и тащит его за собой. Алгоритм следующий: public boolean onTouchEvent(MotionEvent event){
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
touchX = event.getX();
touchY = event.getY();
case MotionEvent.ACTION_UP:
dx = touchX - event.getX();
dy = touchY - event.getY();
if(Math.abs(dy) > Math.abs(dx)){
if(dy > 0){ //Direction UP
manFirstY = manFirstY - 50;
manSecondY = manSecondY - 50;
if(manFirstY < targetSecondY && manFirstX == targetFirstX){
targetFirstY = targetFirstY - 50;
targetSecondY = targetSecondY - 50;
}
}
else if(dy < 0){ //Direction DOWN
manFirstY = manFirstY + 50;
manSecondY = manSecondY + 50;
if(manSecondY > targetFirstY && manFirstX == targetFirstX){
targetFirstY = targetFirstY + 50;
targetSecondY = targetSecondY + 50;
}
}
}
else{
if(dx > 0){ //Direction LEFT
manFirstX = manFirstX - 50;
manSecondX = manSecondX - 50;
if(manFirstX < targetSecondX && manFirstY == targetFirstY){
targetFirstX = targetFirstX - 50;
targetSecondX = targetSecondX - 50;
}
}
else if(dx < 0){ //Direction RIGHT
manFirstX = manFirstX + 50;
manSecondX = manSecondX + 50;
if(manSecondX > targetFirstX && manFirstY == targetFirstY){
targetFirstX = targetFirstX +50;
targetSecondX = targetSecondX +50;
}
}
}
}
return true;
}