I want to build aquarium app live wallpaper in Android in which I draw multiple Bitmap now I want add touch event and when I touch fish should react how I can know which particuler fish is touched how I can do taht
private void draw() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas C = null;
try {
C = holder.lockCanvas();
c.drawColor(Color.BLACK);
if (c != null) {
if (playingcounter3 == 20) {
playingcounter3 = 0;
}
c.drawBitmap(fish_c[1][playingcounter3], x1, 200, null);
if (x > width) {
x = -f1_width - width / 7;
}
}
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
handler.removeCallbacks(drawRunner);
if (visible) {
handler.postDelayed(drawRunner, 10);
}
}
You have to check the pixel values of an on touch event.