Java Reference
In-Depth Information
G.25 anImatIon thread class for contInuous
movement WhIle navIGatInG Icons Is held or
anImatIon mode button Is clIcked
class Animation implements Runnable
{
boolean running = false;
Thread AnimationThread;
public Animation()
{
AnimationThread = new Thread(this);
AnimationThread.start();
//call function run() to begin to measure
}
public void run()
{
try {
AnimationThread.sleep(1000);
} catch (Exception ie) {
System.out.println(“Interrupted Exception!”);
}
while (running)
{
if (viewposi.z>-2.0f)
{
viewposi.z = viewposi.z - 2.0f*SPAN;
setPosition(bodyTrans, viewposi);
setPosition(viewTrans, viewposi);
if (outsideTrans!=null)
setPosition(outsideTrans, new Point3f(Outsidescale*viewposi.x, outsideposi.y,
outsideposi.z));
}
else
{
viewposi.z=-2.0f;
setRotation(viewTrans, ANGLESTEP, comMat, 1);
turningAngle += ANGLESTEP;
}
try {
AnimationThread.sleep(80);
} catch (Exception ie) {
System.out.println(“Interrupted Exception!”);
}
}
AnimationThread.interrupt();
//stop measuring
}
}
}
// end of class NavigatorBehavior
Search WWH ::




Custom Search