How to Drag a bitmap over another Bitmap on Canvas with Surfaceview in Android -


i new using canvas , surfaceview in android.

i trying implement application canvas using surfaceview,and want drag bitmaps on view.i able drag no.of bitmaps.

i have 2 different sizes in bitmaps shown in below image :

image

requirement

  1. big size (bmp1) bitmap - 1

  2. small , equal in dimension/resolution bitmaps(a,b,c,d,e.....) - n(no restriction in number)

3.i have drag a/b/c/... bmp1.and when small bmp reached bmp1 , if in surroundings of relative port(a/b/c/....) connection should establish.

4.so,i have drag bmp on other bmp

problem :

  1. while dragging small bitmap big bitmap when come close small overlapping on big @ center , unable drag small bitmap separately until move big one.

  2. when 2 small bitmaps coming close upper 1 overlapping on lower drawing bitmap , unable separate them.

how avoid these problems?

normal collision detection ... use loop iterate through other bitmaps positions ...in loop check

if(math.abs(draggedbmp.posx-otherbmp.posx)< draggedbmp.width/2+otherbmp.width/2&&math.abs(draggedbmp.posy-otherbmp.posy)< draggedbmp.height/2+otherbmp.height/2) log.e("fatal","overlapping...world explode");

or that..."aabb"<- google that


Comments