How to set position in center of parent node with anchor point (0.5, 0.5) like cocos creator do in c++?
auto parentNode = Node::create();
parentNode->setContentSize(Size(200, 200));
// child
auto sprite = Sprite::create("sample.png");
sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE); // (0.5, 0.5)
sprite->setPosition(parentNode->getContentSize() / 2);
parentNode->addChild(sprite);
How to set this without set position, only change anchor point only?
No. In C++, both coordinates and anchor points must be explicitly set.