Jump to content
  • Advertisement
Sign in to follow this  
pimple

C# - time.ticks

This topic is 5126 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

hello... here's what i'm working on: http://www.geocities.com/antigatez/RigoLib/running.zip anyhoo, that's just the animation part of my project, but i'm both moving the character and animating the sprite based on my counter (using standard Borland C# Builder's counter)... i know how to do both of these things based on time, but i'm not sure what the best way to get the time in C# is... anyone? thanks!

Share this post


Link to post
Share on other sites
Advertisement
Pimple, it depends on how accurate of a resolution you need on the counter. If it doesn't need to be extremely precise, you can simply use DateTime.Now.Ticks. However, if you need to be more accurate than DateTime.Now.Ticks can provide (Windows XP: 10 millisecond resolution; Windows 98: 55 millisecond resolution, I believe), then you will need to resort to using kernel functions like so:


[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
public static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency);

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
public static extern bool QueryPerformanceCounter(ref long PerformanceCount);





I hope this helps! :)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!