I have a CCSprite that is being subjected to a position animation. It is animating perfectly. At some point of time, between starting the animation and reaching the final position, I want to get the exact position of the CCSprite
I know that the sprite.position will return the final position
Here is the animation code:
sprite = [CCSprite spriteWithFile:@"sprite.png"];
[sprite setPosition:ccp(winSize.width/2, 170)];
[self addChild:sprite];
CCMoveTo *moveSpriteUp = [CCMoveTo actionWithDuration:2.0 position:ccp(winSize.width/2, 210)];
CCEaseOut *upEase = [CCEaseOut actionWithAction:moveSpriteUp rate:2];
CCMoveTo *moveSpriteDown = [CCMoveTo actionWithDuration:2.0 position:ccp(winSize.width/2, 170)];
CCEaseOut *downEase = [CCEaseOut actionWithAction:moveSpriteDown rate:2];
CCSequence * spriteMoveSeq = [CCSequence actions:upEase, downEase, nil];
CCRepeatForever *spriteRepeat = [CCRepeatForever actionWithAction:spriteMoveSeq];
[sprite runAction:spriteRepeat];
//1 or 1.x seconds later, the sprite's Y postion will be somewhere between 170 and 210, this is what I want to catch
Any way I can do this?
What about
CCDelayTime
+CCCallFunc
? Something like.-In
getSpritePosition
you could get thesprite
position (assumingsprite
is accessible from your scene scope), and do whatever you need with it.