[Cocos2d-x Study Notes] Three Types of texts, batch processing genie, C ++ four cast, cocos2d-xcast

Source: Internet
Author: User

[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.

 




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.