layout - how to destroy the image button in android? -
i have simple game ..theres snow move down , penguin in bottom layout ..we must protec penguin falling snow
and want ask how can destroy imageview (snow pictures) when click it? set:
lebah2.setvisibility(view.gone); but hidding ..because create timer check collision ..when snow collision penguin live minus 1 ..if put code, timer decrease live ..
for(int awal = 1 ; awal<=akhir; awal++) { imageview lebah2 = (imageview) findviewbyid(awal); int atas = lebah2.gettop(); int left = lebah2.getleft(); if(atas >=180) { if(left >180 && left <240) { data.live--; textview nyawa = (textview) findviewbyid(r.id.live); nyawa.settext(string.valueof(data.live)); lebah2.setvisibility(view.gone); } } what must do?
you can remove view this:
((linearlayout)lebah2.getparent()).removeview(lebah2); you can skip loop if view not visible:
if(iv.getvisibility() == view.visible) { for(int awal = 1 ; awal<=akhir; awal++) { //check if collision } }
Comments
Post a Comment