I wonder if there is a simple way to use some kind om interval timing in XNA? For example call a method every 10 seconds?
I'm also wondering if there is a way to hide and unhide a sprite when it's on the screen?
Thanks!
|
I wonder if there is a simple way to use some kind om interval timing in XNA? For example call a method every 10 seconds? I'm also wondering if there is a way to hide and unhide a sprite when it's on the screen? Thanks! |
|||
|
|
Question 1:To expand on Jason's answer, I typically handle it by creating a couple variables:
Then in the Update() method, you can then do something like this:
Question 2:Create a variable:
Set this variable in your code, depending on where you want to switch it on or off. You could set it inside of your timer action, so it would flip on/off every 10 seconds.
Then in your Draw() function:
|
|||||||||||
|
|
You could have a timer variable, and add gameTime.ElapsedGameTime to it on every update(). As for your second question: in your draw() function, use an if statement for drawing sprites. |
|||
|