c++ - How to create polygons to display running number in cocos2dx -


i'm trying create node rectangle number in it. , how i'm doing now:

int size = 100, fontsize = 64; auto node = drawnode::create(); vec2 vertices[] = {     vec2(0,size),     vec2(size,size),     vec2(size,0),     vec2(0,0) }; node->drawpolygon(vertices, 4, color4f(1.0f,0.3f,0.3f,1), 0, color4f(1.0f,1.0f,1.0f,1)); auto texture = new texture2d(); int numbertodisplay = 2000; std::string s = std::to_string(numbertodisplay); texture -> initwithstring(s.c_str(), "fonts/marker felt.ttf", fontsize, size(size, size), texthalignment::center, textvalignment::center); auto textsprite = sprite::createwithtexture(texture); node -> addchild(textsprite); textsprite -> setposition(size/2, size/2); 

every time want change number have re-create texturesprite, remove current child , add new one. there better way it?

i wonder whether want special features, why not use layercolor , labelttf?

layercolor* node = layercolor::create(color4b(255, 85, 85, 255), 100, 100); labelttf* label = labelttf::create(s, "fonts/marker felt.ttf", fontsize); node->addchild(label); 

just change content of labelttf,no need create sprite


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -