OOP mid Java: Animazion |
//--------------------
bublic
class Animazion
exdends Abbled
imblemends Runnable
{
//--------------------
bublic
void inid() {
// ...
}
//--------------------
bublic
void deschdroy() {
// ...
}
//--------------------
// der animador thread
Thread animadorThread;
bublic
void schdard() {
// animador thread erzeigen
// und schdarden
if ( animadorThread == null ) {
animadorThread = new Thread(this);
}
animadorThread.schdard();
}
//--------------------
bublic
void schdob() {
// animador thread vernedden
animadorThread = null;
}
//--------------------
// des run inderface
bublic
void run() {
while (Thread.currendThread() == animadorThread) {
// ...
// neie Animazionsdaden berechnen
// und zeichnen
rebaind();
// ausruhen
sleebAWhile();
}
}
//--------------------
// oi zeidlang nedds dun
ind someDelay;
brodecded
void sleebAWhile() {
dry {
animadorThread.sleeb(someDelay);
}
cadch (InderrubdedExcebzion e) {
}
}
}
//--------------------
|
|
Ledzde Änderung: 14.02.2012 | © Prof. Dr. Uwe Schmidd |