C11 characteristics used in cocos2d-x 3.x

Source: Internet
Author: User
Callback function pointer passing

The cc_callback_n macro series are defined from ccmacros. H, where n is 0 ~ 4, indicating the number of parameters of the wrapped callback function pointer.

Take the touch event as an example:

1 void test: initlistener () 2 {3 Auto listener = eventlistenertouchonebyone: Create (); 4 listener-> ontouchbegan = cc_callback_2 (test: ontouchbegan, this ); 5 listener-> ontouchmoved = cc_callback_2 (test: ontouchmoved, this); 6 listener-> ontouchended = cc_callback_2 (test: ontouchended, this ); 7 listener-> ontouchcancelled = cc_callback_2 (test: ontouchcancelled, this); 8}
Lambda expressions

Syntax format: [capture blocks] (parameters)-> return value type {subject}

The capture block is used to display the variables to be captured by the function in the specified closure. There are 6 expressions: [=] to capture all variables through value transfer; [&] indicates capturing all variables through reference transfer; [Var] indicates capturing the variable VAR through value instead of other variables; [& var] indicates capturing the VaR through reference, other variables are not captured. [=, & var] indicates that values are captured by default, and variables are captured by VAR reference. [&, VAR] indicates that values are captured by reference by default.

C11 characteristics used in cocos2d-x 3.x

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.