Xna GameTime problem?

Started by
2 comments, last by Lars-Kristian 11 years, 6 months ago
Hi, everyone!

I am making a game for wp7 using silverlight/xna.

In the pre made code the game loop is setup like this:

[source lang="csharp"]GameTimer timer;
public MyGame()
{
timer = new GameTimer();
timer.UpdateInterval = TimeSpan.FromTicks(166666);
timer.Update += OnUpdate;
timer.Draw += OnDraw;
}
private void OnUpdate(object sender, GameTimerEventArgs e)
{
}
private void OnDraw(object sender, GameTimerEventArgs e)
{
}[/source]

When the game runs, it lags precisely one time a second;

From my understanding the GameTimer suspends a frame if the frame is using more time than it should.
My game is pretty simple and the game runs fine on all the other frames, so why is this happening only one time per second?
I have Googled around and this seem to be a common problem. But I can't find a solution to it.

If someone have had this problem or know a solution I would be very happy if you can share it with me. biggrin.png
Advertisement
The code is not displayed the proper way.
Does anyone know how to fix it? :P
Try updating your logic less frequent, let's say 30fps:


TimeSpan.FromMilliseconds(1000.0d / 30.0d);

We are now on Tumblr, so please come and check out our site!

http://xpod-games.com


Try updating your logic less frequent, let's say 30fps:


TimeSpan.FromMilliseconds(1000.0d / 30.0d);



Thanks for a reply, but this did not work for me and the problem is still there.

I used Stopwatch to time my update- and draw method.
Update uses under 1ms and draw under 2ms, so I don't think its because my game is to complex.

This topic is closed to new replies.

Advertisement