dragging an image
<p>I'm trying to make a floating joystick for my android game but am unable to do so.
Here is my onTouch() function:</p>

<pre><code>@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    c = holder.lockCanvas();
    switch (action &amp; MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        float x = event.getX();
        float y = event.getY();
        Log.d("joystick", " " + x + " " + y);
        ondraw(c, x, y);
        break;

    case MotionEvent.ACTION_MOVE:
        d = holder.lockCanvas();
        float xdrag = event.getX();
        float ydrag = event.getY();
        Log.d("joystick move", " " + xdrag + " " + ydrag);
        ondraw(d, xdrag, ydrag);
        break;
    }

    return false;
}
</code></pre>

<p>for some reason the image is not dragging. can someone tell the problem here and help me?</p>

<p>my ondraw is:</p>

<pre><code>protected void ondraw(Canvas c, float x, float y) {

    c.drawColor(Color.BLACK);
    c.drawBitmap(bmpback, x - (bmpback.getWidth() / 2),
            y - (bmpback.getHeight() / 2), null);
    c.drawBitmap(bmpfront, x - (bmpfront.getWidth() / 2),
            y - (bmpfront.getHeight() / 2), null);
    holder.unlockCanvasAndPost(c);
}
</code></pre>
