ZhiYi
2008-09-25 08:35:16 UTC
The effect I would like to get is to see the image move in a circular motion while it rotates. The rotation angle is incremented by 5 degrees each time the key pressed event handler executes.
The problem is that while the image does move in a circular path, a string of previously rotated images appear along the rotation path instead of just the latest rotated image.
i.e. If the maximum angle is set to 20 degrees, 4 images will be on the screen with the first rotated at 5 degrees, the next at 10 degrees and so on.
How do I just show a single bitmap image rotating instead of a string of previous images showing up along the rotation path?
The code is shown below:
[code]
(in the form1 load event)
Graphics g = CreateGraphics();
granade = new Bitmap("granade.jpg");
(in the form1 paint event)
g.DrawImage(granade,0,0,20,20);
(in the key down event)
Matrix rotMatrix = new Matrix();
rotateAngle -= 5;
rotMatrix.RotateAt(rotateAngle);
g.Transform = rotMatrix;
[/code]