[Cocos2d-x Study Notes] Three Types of texts, batch processing genie, C ++ four cast, cocos2d-xcast
Three types of display text
CCLabelTTF, CCLabelAtlas, CCLabelBMFont
CCLabelTTF: a texture is generated for each character string in the system font, resulting in low display efficiency. Suitable for non-changing text
CCLabelAtlas: Uses NodeAtlas to optimize rendering and is suitable for frequently changing numbers, such as scores and money.
CCLabelBMFont: it is flexible to use CCSpriteBatchNode. Each character is an Genie and can be operated on every character.
CCLabelAtlas * lable = CClabelAtlas: create ("12434", "labelatlasing.png", 24, 32, '0'); according to the Cisco code, the sequence cannot be changed.
CCLabelBMFont * label = CCLabelBMFont: create ("abc", "bitmapFontTest. fnt"); font Based on the image. The principle is the batch processing genie.
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 operated separately
PS: use images directly and draw texts on images (Restrictions: resolution, trouble changing, etc)
CCSpriteBatchNode is also a container, but it can only accommodate CCSprite objects and requires these genie to come from the same texture.
CCSpriteBatchNode * batch = CCSpriteBatchNode: create ("CloseNormal.png ");
AddChild (batch );
CCSprite * sprite = CCSprite: createWithTexture (batch-> getTexture ());
Batch-> addChild (sprite );
Four types of C ++ cast
C ++ introduces cast to reduce errors caused by type conversion and check conversion problems during compilation and running.
Static_cast checks during compilation. Both sides of cast require that one side be implicitly converted before static_cast can be used.
Dynamic_cast is a runtime check, used for type conversion between the parent class and subclass with virtual functions
Const_cast converts a constant to a constant
Reinterpret_cast is called re-interpretation, which is useless.