Either I'm missing something basic, or there's a bug in SPTween.
I have a "balloon" class derived from SPSprite that has a tween attached to it:
// In init function of class myBalloon (subclass of SPSprite)
mTween2 = [SPTween tweenWithTarget:self time:10 transition:SP_TRANSITION_LINEAR];
[mTween2 animateProperty:@"y" targetValue:-50];
mTween2.repeatCount = 1; // repeat indefinitely
mTween2.reverse = NO;
The tween makes the balloon float upward.
When an event occurs, I want to reset the balloon to the bottom of the screen and then float up again. So I remove the old tween, set self.y, and attach a new tween:
// remove all tweens, including the one that makes the balloon float up
[Sparrow.juggler removeObjectsWithTarget:self];
// reset pos
self.y = 770; // place at bottom of screen
// attach the tween again
mTween2 = [SPTween tweenWithTarget:self time:10 transition:SP_TRANSITION_LINEAR];
[mTween2 animateProperty:@"y" targetValue:-50];
mTween2.repeatCount = 1; // repeat indefinitely
mTween2.reverse = NO;
I expect the result to be that the balloon is "reset" to the bottom of the screen, and then floats up from there.
What actually happens is that the balloon continues floating up from the same place on the screen as it previously. I'm resetting self.x to a random value as well, so what actually happens is that the balloon seems to "jump" horizontally and then continue its upward motion.
I've traced the balloon's y position through a callback for the SP_EVENT_TYPE_ENTER_FRAME event, and I can see that it seems to continue from its previous (tweened) y position even after it's reset to 770.
I've dug into this as much as possible, and I don't see any bug in my code. Is there something I'm doing wrong, or is the previous SPTween somehow not getting detached from the object and preventing its y value from being reset?