Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7840205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:41:58+00:00 2026-06-02T15:41:58+00:00

When I use XNA Framework (For windows Phone) my game work perfectly, but when

  • 0

When I use XNA Framework (For windows Phone) my game work perfectly, but when I migrate on Silverlight/XNA Framework I got a problem with animation lagging.
The problem is the following:
When I set fixed time step to GameTimer (timer.UpdateInterval = TimeSpan.FromTicks(333333)), the REAL time step doesn’t FIXED and timer events (OnUpdate, OnDraw) fires with different intervals.
This code shows my problem more clearly:

Silverlight/XNA Framework: (Animation lagging):

TimeSpan curNow;
TimeSpan lastUpdate;
TimeSpan lastDraw;

public GamePage()
{
    timer = new GameTimer();
    timer.UpdateInterval = TimeSpan.FromTicks(333333);
    timer.Update += OnUpdate;
    timer.Draw += OnDraw;
}

private void OnUpdate(object sender, GameTimerEventArgs e)
{    
    curNow = new TimeSpan(DateTime.Now.Ticks);
    TimeSpan elapsed=e.ElapsedTime;//Always constant and has value: 33ms
    TimeSpan realElapsed =  curNow  -  lastUpdate;//Real elapsed time always changing and has a value between: 17-39ms (sometimes more then 39ms)
    lastUpdate =  curNow;
}

private void OnDraw(object sender, GameTimerEventArgs e)
{
    curNow = new TimeSpan(DateTime.Now.Ticks);
    TimeSpan elapsed=e.ElapsedTime;//Always changing and has a value between: 17-39ms (sometimes more then 39ms)
    TimeSpan realElapsed =  curNow  -lastDraw;//Always changing and has a value between: 17-39ms (sometimes more then 39ms)
    lastDraw=  curNow;
}

XNA Framework: (All works fine):

TimeSpan curNow;
TimeSpan lastUpdate;
TimeSpan lastDraw;

public Game()
{
    // Frame rate is 30 fps by default for Windows Phone.
    TargetElapsedTime = TimeSpan.FromTicks(333333);
}

protected override void Update(GameTime gameTime)
{    
    curNow = new TimeSpan(DateTime.Now.Ticks);
    TimeSpan elapsed=gameTime.ElapsedGameTime;//Always constant and has value: 33ms
    TimeSpan realElapsed =  curNow - lastUpdate;//Real elapsed time has a value between: 34-35ms (sometimes more then 35ms)
    lastUpdate = curNow;
}

protected override void Draw(GameTime gameTime)
{    
    curNow = new TimeSpan(DateTime.Now.Ticks);
    TimeSpan elapsed=gameTime.ElapsedGameTime ;//Value between: 33-34ms (sometimes more then 34ms)
    TimeSpan realElapsed = curNow - lastDraw;//Value between: 34-35ms (sometimes more then 35ms)
    lastDraw = curNow;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:42:00+00:00Added an answer on June 2, 2026 at 3:42 pm

    Based on many years in (and out) of the video games industry: you should not animate against a fixed frame rate in Silverlight/XNA/Mobile.

    If possible, change your app to run solely off the game time, rather the operate against an assumed fixed frame-rate (which you will never get on a mobile device – at least until they are a lot more powerful).

    The reason XNA game methods take a GameTime is because you cannot rely on the frame rate… ever.

    Don’t fight city hall… go with the standards. Make your app as fast as possible (e.g. if your animations skip too far in a frame), or slow down your animation rate to suit the platform (i.e. slow down your game/app).

    Note: The reason why Silverlight animation usually looks smoother than Flash animation is because everything is time based and interpolated, not fixed frame.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen a similar query here But I want to use XNA framework
I write some application on XNA for Windows Phone 7. I need to use
Hey all, I'm just beginning to use XNA 4.0 for Windows Phone 7 and
I'm making a game using XNA framework, so I use a lot functions that
I keep reading tutorials of how to use it in Silverlight Apps, but I
I'm learning how to use the XNA framework in C#, and I'm struggling with
using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace proj { public class game
I'm currently making a game for WP7 which is mostly made in Silverlight. But
This piece of code has been taken from a game built with XNA framework.
Does anybody know if its possible to use Microsoft.Xna.Framework.Media.MediaLibrary for design time data? I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.