fix switchToMenu assuming nodes to have a parent

This commit is contained in:
HJfod 2023-07-29 20:39:25 +03:00
parent ff9231db18
commit 8027b807e5

View file

@ -35,7 +35,9 @@ void setIDs(CCNode* node, int startIndex, Args... args) {
static void switchToMenu(CCNode* node, CCMenu* menu) {
if (!node || !menu) return;
auto worldPos = node->getParent()->convertToWorldSpace(node->getPosition());
auto worldPos = node->getParent() ?
node->getParent()->convertToWorldSpace(node->getPosition()) :
node->getPosition();
node->retain();
node->removeFromParent();