I want to rotate my sprite around another sprite,has anyone do this type task ?
I think, you can set the anchor point of the target sprite to position of another sprite and simply rotate the target sprite then…
There are 2 ways to do this.
float angle; //increment this to make the rotation
float radius; // radius of the circle //distance between sprite1 and sprite2
sprite1->setPosition(sprite2->getPosition().x + radiussinf(CC_DEGREES_TO_RADIANS(angle)) , sprite2->getPosition().y + radiuscosf(CC_DEGREES_TO_RADIANS(angle)));
2nd method
Sprite2->setPosition(sprite1->getposition);
sprite2->setAnchorPoint(Point(5,0.5));
sprite2->runAction(RepeatForever::create(rotateBy::Create(1,30))));
// something like this should work aswell but boundingbox on sprite2 will give and incorrect position