C# - time.ticks
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!
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:
I hope this helps! :)
[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! :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement