I'm quite new in XNA C# and I would like to know how do I create a timer in XNA C# that does something after few seconds.
I've seen a Flash tutorial that does what I need but I don't know how to do it in XNA C#
I'm trying to use a timer to make a blinking model in certain period of my project. Therefore, I need to know how do I start the timer and how does the timer toggle the blinking of my model.
Thanks.
Do something like below in update
float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
then have a variable for seconds like
float timer = 5.0f; // Five seconds
then in update
timer -= elapsedTime
if(timer <= 0)
{
// Hanlde the blink here
timer = 5.0f; // Reset timer
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With