Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 11:12:18 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Animatable
Pages: [1]
Print
Author Topic: Animatable  (Read 843 times)
Jotschi
Enjoying the stay
*
Offline Offline

Posts: 55



View Profile
« on: 25. June 2007, 11:57:27 pm »



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?
              
Code:
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;
}



}

Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 26. June 2007, 12:44:27 am »

Yes, this is the best way. And setAlive( false ) is the way to remove the ScheduledOperation from the scheduler. But this caanot have any effect, if you return a constant 'true' is isAlive() Wink. See?

Marvin
Logged
Jotschi
Enjoying the stay
*
Offline Offline

Posts: 55



View Profile
« Reply #2 on: 26. June 2007, 10:37:12 am »

Ups! Cheesy

Okay i see..

Its very good that i get the gametime and the time the rendingloop (frametime) takes. Right know i don't know how to write a method that will preform a given task in the same speed. Mh.. will investigate that.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 26. June 2007, 10:47:17 am »

Its very good that i get the gametime and the time the rendingloop (frametime) takes. Right know i don't know how to write a method that will preform a given task in the same speed. Mh.. will investigate that.

Please also have a look at AngleInterpolator and DistanceInterpolator.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic