I'm creating a 2d platform game with cocos2d-x v3.2 (c++) and i'm using label.
cocos2d-x v3.0 (c++)
declared like cocos2d::LabelTTF* currentScore;
cocos2d-x v2.2.2 (c++)
declared like cocos2d::CCLabelTTF* currentScore;
cocos2d-x v3.2(c++) how to declare label in global class(helloworld.h) i have try like
HelloWorld.h
class HelloWorld : public cocos2d::LayerColor
{
public:
virtual bool init();
cocos2d::LabelTTF* currentScore; //semantic issue(LabelTTF deprecared)
};
#endif
HelloWorld.cpp
bool HelloWorld::init()
{
currentScore = LabelTTF::create("", "Arial", 40); //semantic issue(LabelTTF deprecared)
// position the label on the center of the screen
currentScore->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - currentScore->getContentSize().height));
// add the label as a child to this layer
this->addChild(currentScore, 1);
char buffer[10];
sprintf(buffer, "%04i",0);
currentScore->setString(std::string(buffer));
}
one more try again
HelloWorld.cpp
bool HelloWorld::init()
{
Auto currentScore = LabelTTF::create("", "Arial", 40);
//position the label on the center of the screen
currentScore->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - currentScore->getContentSize().height));
// add the label as a child to this layer
this->addChild(currentScore, 1);
}
#endif
it working but can't "Auto currentScore;" declared in global class(HelloWorld.h)