Sign in to follow this  

Xna GameTime problem?

This topic is 1912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] Edited by Lars-Kristian

Share this post


Link to post
Share on other sites
Try updating your logic less frequent, let's say 30fps:

[CODE]
TimeSpan.FromMilliseconds(1000.0d / 30.0d);
[/CODE] Edited by AmzBee

Share this post


Link to post
Share on other sites
[quote name='AmzBee' timestamp='1350903299' post='4992722']
Try updating your logic less frequent, let's say 30fps:

[CODE]
TimeSpan.FromMilliseconds(1000.0d / 30.0d);
[/CODE]
[/quote]

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.

Share this post


Link to post
Share on other sites
Sign in to follow this