Original Post
🔒 Locked
[java] for the most inteligent ones :)
Advertisement
well, in this case, my point was that I''m the stupid one, witch
this only proves.. hehe
anyway, the timer problem is my bigest one, here are how I do it:
---------------------------------------
Declare a Date variable, and two timer variables:
public Date timer = new Date();
public long startTime;
public long stopTime;
then, when I''m initializing, I get the startTime by writing startTime = timer.getTime();
at last I get the stopTime every frame and compare it against the startTime:
stopTime = timer.GetTime();
if( (stopTime-startTime) > delayTime ) {
currentFrame++;
}
---------------------------------------
This doesn''t do anything, shouldn''t it be right?
Hans-Petter
this only proves.. hehe
anyway, the timer problem is my bigest one, here are how I do it:
---------------------------------------
Declare a Date variable, and two timer variables:
public Date timer = new Date();
public long startTime;
public long stopTime;
then, when I''m initializing, I get the startTime by writing startTime = timer.getTime();
at last I get the stopTime every frame and compare it against the startTime:
stopTime = timer.GetTime();
if( (stopTime-startTime) > delayTime ) {
currentFrame++;
}
---------------------------------------
This doesn''t do anything, shouldn''t it be right?
Hans-Petter
A
Data object represents a single point in time, in this case the time at which it was created. For internal timing use System.currentTimeMillis()
You may just want to note that currentTimeMillis can be quote innacurate on some platforms ( windows ) so that it will only change every 50 ms ~ 18 times a second.
If you need more accuracy you have a few options.
1) Use a native library
2) Use Sun JDK 1.4.2 or better and a sun.* class ( will be stock java in 1.5 finally )
3) Use a terrible hack in 100% java that I wrote a while ago that cannot give you an exact time but approximates 30 ticks per second quite well.
If you need more accuracy you have a few options.
1) Use a native library
2) Use Sun JDK 1.4.2 or better and a sun.* class ( will be stock java in 1.5 finally )
3) Use a terrible hack in 100% java that I wrote a while ago that cannot give you an exact time but approximates 30 ticks per second quite well.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement