Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Xna GameTime problem?


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   -  Reputation: 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.


Sponsor:

#2 Lars-Kristian   Members   -  Reputation: 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 AmzBee   Members   -  Reputation: 416

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.

Aimee Bailey
Lead Programmer / Co-Founder

http://xpod-games.com
@XpodGames

#4 Lars-Kristian   Members   -  Reputation: 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.



PARTNERS