据我所知,您不应该使用moveTo
方法来为精灵设置动画。你有没有注意到,当你使用“moveto”时,你的移动并不顺畅?
我是这样做的,可能并不完美。
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [zoombase convertTouchToNodeSpace:myTouch];
self.destinationLocation = loaction;
}
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [zoombase convertTouchToNodeSpace:myTouch];
self.destinationLocation = loaction;
}
-(void)update:(ccTime)dt {
//that will do until your sprite reach you destination point
if(!CGPointEqualToPoint(self.spriteToMove,self.destinationLocation)) {
CGPoint *stepToMove = ccp(0.2/destinationLocation,0.2/destinationLocation); //some piece of orginal destination
[self.spriteToMove setPosition:ccpAdd(stepToMove,self.spriteToMove.position)]; // add that pice to your sprite current location
}
}