Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, i'm trying to reproduce sprites animations using the ObjectAnimation and a Sprite class that is basicaly a rectangle, but the problem is: if a insert three or more values to the class animate between, he just consider two values, the first and the last, when the evaluate method from my evaluate class is called, the fraction only interpolate between 0.0 and 1.0, no intermediate, so i do not have an animation, here is my test code:

Java
animation = ObjectAnimator.ofObject(object, "update", new SpriteEvaluator(), 
                                new Sprite(0, 0, 32, 32, 100, 3), 
				new Sprite(64, 0, 32, 32, 100, 3),
				new Sprite(32, 0, 32, 32, 100, 3));	
		
animation.start();


EDITED___: The four first parameters of the Sprite class are the most important here:
x, y, w,h, delay, count.

The SpriteEvaluator class is here:

Java
private class SpriteEvaluator implements TypeEvaluator<Sprite>{

	@Override
	public Sprite evaluate(float fraction, Sprite startValue, Sprite endValue) {
		//multiply the fraction by the total to obtain the current sprite.
		int c = (int)fraction*(startValue.count-1);
			
		return new Sprite(startValue.w*c, startValue.y, startValue.w,                                                           startValue.h, startValue.delay, startValue.count);
	}
}


am i doing something wrong?? cause i've see some examples that use more than 3 values and works good, i'm almost giving up and drop this thing to create my own animation class in the C++ style, where i can ask to the class if is time to actualize in the main loop, but how this is android, i'm afraid to do things by the "old" way.

Thank you all already.
Posted
Updated 25-Feb-14 14:55pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900