I want to get position of sprite while it is moving……which is moving by CCMoveTo action………is it possible or not ?? if yes then how
It’s not possible. But actually there is if you’re really just want to know the position and I would rather avoid this kind of approach. Just create a schedule with interval function, you can check the position from there. And then after your sprite is done moving, you could call the unschedule function.
// inside init function schedule(schedule_selector(self::moving), 100); runAction(CCSequence::create(CCMoveTo::create(500, ccp(300, 300)), CCCallFunc::create(this, schedule_selector(self::afterMoving)), NULL)); //inside moving function cout << "x: " << mySprite->mySprite->getPositionX() << "y: " << mySprite->getPositionY(); << endl; //inside afterMoving function unschedule(schedule_selector(self::moving));
My approach would be not to use CCMoveTo at all. I would create a schedule to move the sprite and then after the sprite has moved to the position that I want it, I will unschedule it.