I have a sprite class which has a draw method which draws an explosion.
The class has an image property which is used as the image that will be drawn.
I wish to have it so that the image that is draw is changed every 5 seconds or so.
My question is: Using a timer control, how can I code it so the Image property is changed to a different image each tick?
For example, Image 1 ‘5 seconds’ > Image 2 ‘5 seconds’ > Image 3 ‘5 seconds’ > remove image.
Here is the draw method:
public void DrawExplosion(Graphics graphics)
{
graphics.DrawImage(explosion_, xPos_, yPos_);
}
and the Image property of the class
public Image Explosion
{
get {return explosion_;}
set {explosion_ = value;}
}
Thanks for any help/guidance.
i noticed my answer was far to complex for the simple question asked. While I don’t believe it is incorrect I do think it complicates the matter. I wanted to leave it there in case someone else finds it useful. But here is a simplified attempt. It uses a timer external to the Sprite class, a button and a panel. I hope this is helpful.