c# - Completely remove a picturebox from project? -
i have project in dynamically create pictureboxes run 1 side of screen another. user needs click pictureboxes and, when clicked, dissapear. however, if picturebox gets 1 side of screen another, life lost. problem is, lives seem dissapear randomly. suspect because pictureboxes aren't removed project , somehow keep travelling after clicked them. code. thank :).
//the movement timer
private void timermovement_tick(object sender, eventargs e) { int i; (i = 0; < zombie.count(); i++) { int x = zombie[i].img.location.x; int y = zombie[i].img.location.y; if (zombie[i].loc == 0) { x = x + 10; if (zombie[i].img.location.x > 1200 && zombie[i].img != null) { zombie[i].img.dispose(); this.controls.remove(zombie[i].img); label5.text = convert.tostring(zombies_total - zombies_killed - 1); life_remove(); label7.text = convert.tostring(i); } } else { x = x - 6; if (zombie[i].img.location.x < -100 && zombie[i].img != null) { zombie[i].img.dispose(); this.controls.remove(zombie[i].img); label5.text = convert.tostring(zombies_total - zombies_killed - 1); life_remove(); label7.text = convert.tostring(i); } } point p = new point(x, y); zombie[i].img.location = new point(x, y); }
//life removal
private void life_remove() { if (pictureboxlife1.visible == true) pictureboxlife1.visible = false; else if (pictureboxlife2.visible == true) pictureboxlife2.visible = false; else if (pictureboxlife3.visible == true) pictureboxlife3.visible = false; }
Comments
Post a Comment