unable to erase the rectangle drawn
-
I am developing a card game. To show the card selected, i am drawing one rectangle to highlight the card.Following is the code i am using to draw rectangle on different card positions: Pen Blue = new Pen(Color.Blue, 2); e.Graphics.DrawRectangle(Blue, 199, 300, 73, 97); While selecting the card, it is getting drawn but at the same time if "deselected" then it(rectangle) should be erased. I tried in many ways to erase the drawn rectangle but while erasing cards which are drawn are also get erased. Please assist me.
-
I am developing a card game. To show the card selected, i am drawing one rectangle to highlight the card.Following is the code i am using to draw rectangle on different card positions: Pen Blue = new Pen(Color.Blue, 2); e.Graphics.DrawRectangle(Blue, 199, 300, 73, 97); While selecting the card, it is getting drawn but at the same time if "deselected" then it(rectangle) should be erased. I tried in many ways to erase the drawn rectangle but while erasing cards which are drawn are also get erased. Please assist me.
I would think the simplest method would be to redraw the display without the blue highlighting rectangle. This would be the same code method that got you this point (before you selected the card). If that doesn't seem feasible, you could draw the highlighting rectangle in whatever color the background is (assuming the background isn't an image). You don't tell us what mechanism you are using to maintain the state of your game's display (so, I'm assuming that there isn't one). But, if you expect the game to get more complex, you might consider such a concept.