Three types of display text
Cclabelttf, Cclabelatlas, Cclabelbmfont
Cclabelttf: Using system fonts each string generates a texture that is less efficient to display. Suitable for non-changeable text
Cclabelatlas: Use Nodeatlas to optimize rendering, suitable for frequently changing numbers, such as fractions, money.
Cclabelbmfont: Using Ccspritebatchnode, very flexible, each character is a sprite, you can operate on each character.
Cclabelatlas *lable = cclabelatlas::create ("12434", "Labelatlasing.png", 24, 32, ' 0 '); According to the Cisco code, the order cannot be changed.
Cclabelbmfont *label = cclabelbmfont::create ("abc", "Bitmapfonttest.fnt"); According to the picture to get the font, the principle is batch Processing wizard
Ccarray *arr = Label->getchildren (); Get all characters
Ccsprite *spritea = (Ccsprite *) arr->objectatindex (0); 0 indicates the first character
Spritea->setrotation (90); Each character can be individually manipulated.
PS: Direct use of the picture, the text is drawn on the picture (limitation: Resolution, Replacement trouble, etc.)
Ccspritebatchnode is also a container, but he can only tolerate ccsprite objects, and requires these sprites to come from the same texture.
Ccspritebatchnode *batch = ccspritebatchnode::create ("Closenormal.png");
AddChild (Batch);
Ccsprite *sprite = Ccsprite::createwithtexture (Batch->gettexture ());
Batch->addchild (sprite);
4 types of cast in C + +
C + + introduced cast is to reduce the errors caused by type conversion, to check the conversion problem at compile, run time
Static_cast is in the compile time check, cast on both sides of the side can do implicit conversion, in order to use static_cast
Dynamic_cast is a run-time check for type conversions between a parent class and a subclass that has a virtual function
Const_cast Convert a constant to a very good amount
Reinterpret_cast, which is called re-interpretation, is of no use.
"Cocos2d-x Study Notes" Three types of text class, Batch wizard, C + + four kinds of cast