auto label = CCLabelTTF::create("Hello World", "Arial", 24); label->setPosition(Vec2(100, 100)); addChild(label);
auto label = CCLabelTTF::create("Score: 0", "Arial", 24); label->setPosition(Vec2(400, 300)); addChild(label); // Update the score int score = 100; label->setString("Score: " + std::to_string(score));This code creates a label that initially says "Score: 0" with the Arial font and font size of 24. It sets the position of the label to (400, 300) using the setPosition method. Later on, the code updates the score and changes the text of the label using the setString method. It adds the updated score to the original string "Score: " using std::to_string. Package library: Cocos2d-x.