Hallo,
ich will in Java eine Animation realisieren… ich weiss aber
nicht wie leistungsfähig die zugrundeliegende Hardware ist.
sieh dir mal javax.swing.Timer an.
der bricht laufende Threads ab wenn ihr Resultat eh zu spät kommt. (skipped also Frames…)
oder benutz was in der Art: (stammt aus der Demo/Applet/Animator/Animator.java die bei SDK 2 dabei ist).
public void run() {
Thread me = Thread.currentThread();
if (animation.frames == null)
return;
if ((appWidth = animation.frames.size()) {
if (animation.repeat)
animation.currentFrame = 0;
else return;
}
// Pause for duration or longer if user paused
try {
Thread.sleep(thisFrame.duration);
synchronized(this) {
while (userPause) {
animation.stopPlaying();
wait();
}
}
}
catch (InterruptedException e) {
}
}
} finally {
synchronized(this) {
if (engine == me)
animation.stopPlaying();
}
}
}
Geht bis zu einem gewissen Grad da keine Frames übersprungen werden. (geht aber sehr gut mit Dia-shows.)
(Ich hoffe der Code ist klar...)
cu