Prev | Current Page 988 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

When
we ran this example on our laptop, we managed to achieve around 250 frames per second maximum,
though in all likelihood, we probably exceeded this somewhat. Now, when you come to write an
application with NME, you ??™ re not likely to want to have your graphics updated at this speed. For most,
this is far too fast and will result in a comical high - speed animation effect that will render most games
unplayable. To avoid this, the Manager class provides a method called delay , which is a means to pause
the application for a set number of milliseconds, allowing for a reasonable slowdown in frame rate.
var milliseconds : Int = 1 / preferredFPS;
mng.delay( milliseconds );
When you use this method, the operating system leaves the current thread of execution, allowing for
other applications running at that time to perform their processing. The exact number of milliseconds
the delay will last will likely vary by around 10 milliseconds, because of the nature of thread execution.
Now, a word of warning when using delay ; it is usually better to use this method when running your
Chapter 19: Multimedia with Neko
537
application full screen.


Pages:
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000