The class animator implements the interface Animatable:
The constructor of animator gets a reference from its 'main class'
Animator anim = new Animator(this);
this.scheduleOperation(anim);
I start the scheduler by just schedule it
How can i stop the schedule 'task'?I used the reference to unschedule the 'task' from the main class:
home.unscheduleOperation(this);
//this.stopAnimation(); // <- no effect
//this.setAlive(false); // <- no effect
stopAnimation(); and setAlive(false); had no effect on the schedule. Is that a bug?
Btw: I just want to activate a task to preform an animation within a specific time. Using Animatable interface was the best option i could figure out because the executeOperation semms to be synchonized with the rendering loop. If i want to change the position and settings of an object in realtime this is the best way, isnt it?
import org.xith3d.behaviors.Animatable;
public class Animator implements Animatable
{
DirectLightingTest home;
Animator(DirectLightingTest home)
{
this.home = home;
}
public boolean isAlive()
{
return true;
}
public boolean isAnimating()
{
return true;
}
public void startAnimation(long time)
{
}
public void stopAnimation()
{
}
public void setAlive(boolean a )
{
}
int i = 0;
public void executeOperation(long gameTime, long frameTime)
{
if(i>100)
{
home.unscheduleOperation(this);
//this.stopAnimation(); // <- no effect
//this.setAlive(false); // <- no effect
}
System.out.println("bla " +i + " - " + gameTime + " - " + frameTime);
i++;
}
public boolean isPersistent()
{
return true;
}
}