Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Xna GameTime problem?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Lars-Kristian   Members   

158
Like
0Likes
Like

Posted 21 October 2012 - 12:41 PM

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. Posted Image

Edited by Lars-Kristian, 21 October 2012 - 12:45 PM.


#2 Lars-Kristian   Members   

158
Like
0Likes
Like

Posted 21 October 2012 - 12:49 PM

The code is not displayed the proper way.
Does anyone know how to fix it? :P

#3 Tarika   Members   

485
Like
0Likes
Like

Posted 22 October 2012 - 04:54 AM

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

TimeSpan.FromMilliseconds(1000.0d / 30.0d);

Edited by AmzBee, 22 October 2012 - 04:55 AM.

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

 

http://xpod-games.com


#4 Lars-Kristian   Members   

158
Like
0Likes
Like

Posted 22 October 2012 - 11:02 AM

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.