"Cocos2d-x Study Notes" Three types of text class, Batch wizard, C + + four kinds of cast

Source: Internet
Author: User
Tags addchild

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

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.