Hey guys, I'm having some trouble getting code to slide my spsprite out of the screen to work. I have a custom class that is a child of SPSprite, and I would like the slide out code to be contained inside that class. Below is how I'm currently trying to do it:
mContents is a SPSprite that contains all visuals. textField is a child of mContents and is of type HMTextField (which inherits from SPSprite), and is also stored as an instance variable.
in Game.m:
[textField slideOut]; // slide out the current textfield</p> textField = [[HMTextField alloc] initWithText:@"TEST" width:self.height*0.65 height:self.width/3]; // create new textfield textField.y = 0.8*(self.width/3); textField.x = -textField.width; [mContents addChild:textField atIndex:1]; [textField release]; [textField slideInToX:(self.height*0.95)-(textField.width)]; //slide in the new textfield
Below are my slide in and slide out functions in my HMTextField class. The weird thing is that the slideIn works, but slideOut doesn't. Also, if I add a Tween completed event listener to the slideOut tween, it is never called :S
-(void)slideInToX:(float)goalX { SPTween *slideIn = [SPTween tweenWithTarget:self time:1.5 transition:SP_TRANSITION_EASE_OUT]; [slideIn animateProperty:@"x" targetValue:goalX]; [self.juggler addObject:slideIn]; } -(void)slideOut { SPTween *slideOut = [SPTween tweenWithTarget:self time:1.5]; [slideOut animateProperty:@"x" targetValue:self.stage.height+self.width]; [self.juggler addObject:slideOut]; [[self.juggler delayInvocationAtTarget:self byTime:1.5] removeFromParent]; }
The old textfield will just stay in its place, with the new one sliding over it. Can anyone see what is the problem here?