2

How do I scroll the background image on an ACTION_MOVE event?

Here is my code used to draw the background image:

void drawFrame() {
    final SurfaceHolder holder = getSurfaceHolder();

    Canvas c = null;
    try {
        c = holder.lockCanvas();
        if (c != null) {
            c.drawBitmap(myBg, 0, 0, mPaint);
        }
    } finally {
        if (c != null) holder.unlockCanvasAndPost(c);
    }

    // Reschedule the next redraw
    mHandler.removeCallbacks(mDrawAnim);
    if (mVisible && mAnime) {
        mHandler.postDelayed(mDrawAnim, 50 );
    }
}
Adam Wenger
  • 17,100
  • 6
  • 52
  • 63

0 Answers0