我有一排球。 我想,当我采取行动时,球队将走向这一位置。 我的这部法典:
public boolean onTouchEvent(MotionEvent event){
if(event.getAction()==MotionEvent.ACTION_DOWN){
x1 = (int) event.getX();
y1 = (int) event.getY();
float dx = x1-x;
float dy = y1-y;
float d = (float)Math.sqrt(dx*dx+dy*dy);
vx = dx*4/d;
vy = dy*4/d;
}
}
页: 1
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
Matrix matrix = new Matrix();
matrix2.postTranslate(x - bitmap.getWidth()/2, y - bitmap.getHeight()/2);
x = x+vx ;
y = y+vy ;
canvas.drawBitmap(bitmap, matrix, null);
}
当......时,气球将走向行动方向。 但是,为什么气球处于从下至下的行动之中?
Please help me? Thank you?