0
我有2幅圖像,圖像A和圖像B.我想知道圖像A移動到B併發生碰撞時,如何檢測此圖像?兩幅圖像之間的碰撞檢測
這是我的代碼:
case MotionEvent.ACTION_MOVE:
builder.append("move, ");
if (mode == DRAG)
{
matrix.set(savedMatrix);
// create the transformation in the matrix of points
matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
builder.setLength(0);
builder.append(event.getX());
builder.append("x , y ");
builder.append(event.getY());
text = builder.toString();
Log.d("TouchTest", text);
txtimage = (TextView)findViewById(R.id.txt);
txtimage.setText(text);
float aX = event.getX();
float aY = event.getY();
String a = Float.toString(aX);
String b = Float.toString(aY);
if (image.getWidth()/2 == image2.getWidth()/2 &&
image.getHeight()/2 == image2.getHeight()/2)
{
Toast.makeText(Multi_touchActivity.this, "collision",
Toast.LENGTH_SHORT).show();
}
}