I want a bitmap to follow my finger. But when I use MotionEvent.ACTION_MOVE the bitmap lags behind. Is there a way the bitmap follows instantly (or almost instantly) your finger?
public boolean onTouch(View v, MotionEvent me)
{
// TODO Auto-generated method stub
switch(me.getAction())
{
case MotionEvent.ACTION_DOWN:
if(me.getX() > player.get_RectXPos() && me.getX() < player.get_RectXPos() + player.get_Width() &&
me.getY() > player.get_RectYPos() && me.getY() < player.get_RectYPos() + player.get_Height())
{
isDown = true;
}
break;
case MotionEvent.ACTION_UP:
isDown = false;
break;
case MotionEvent.ACTION_MOVE:
if(isDown == true)
{
player.set_xPos(me.getX());
player.set_yPos(me.getY());
}
break;
}
return true;
}
I think you asked for this part:
void render(Canvas canvas)
{
m_Src = new Rect(0, 0, m_RectWidth, m_RectHeight);
m_Dst = new Rect(m_RectX, m_RectY, m_RectX + m_RectWidth, m_RectY + m_RectHeight);
canvas.drawBitmap(m_Bitmap, m_Src, m_Dst, null);
}