650) This. width = 650; "src =" http: // 183.61.143.148/group1/m00/02/18/tz2plfqb3cozvu1eaadqgyc0bzg837.png "/>
Added in v3.0beta
It is defined in the header file "ccvalue. H" of "cocos2dx_root/Cocos/base. Recommended tutorialsCocos2d-x from scratch video tutorial
Class value;
Cocos2d: value is a number of basic types (INT, float, double, bool, unsigned char, char *, and STD: string) and STD: vector, STD :: the packaging types of unordered_map and STD: unordered_map classes.
You can put the basic classes mentioned above into the cocos2d: value object to convert them to the corresponding type, and vice versa.
Cocos2d: The underlying value uses a unified variable to save any basic type value, which saves more memory. Before the cocos2d-x v3.0beta, the basic type packages such as ccbool, ccfloat, ccdouble, and ccinteger were used, but they will be discarded.
Note: When processing basic types and containers, use cocos2d: vector, cocos2d: map and cocos2d: value.
Memory Management
Cocos2d: the memory of the value is released by its destructor. Therefore, use the recommended best practices when using cocos2d: value.
Cocos2d: value contains the following data members:
650) This. width = 650; "src =" http: // 183.61.143.148/group1/m00/02/18/tz2plfqb3egqdnwjaaavxab7cbm641.png "/>
In the code snippet, _ basedata, _ strdata and _ type are released by the compiler and Their destructor, while cocos2d :: value destructor are responsible for releasing pointer members (_ vectordata, _ mapdata and intkeymapdata ).
Note: cocos2d: value cannot use retain/release and refcount memory management like other cocos2d types
Best use
1. cocos2d: Value and the new template container (cocos2d: vector and cocos2d: Map) are better than cocos2d: ccbool, cocos2d: ccfloat, cocos2d: ccdouble, cocos2d: ccstring, cocos2d: ccinteger and old objective-C-style containers (cocos2d: ccarray and cocos2d: ccdictionary ).
2. When you want to use the aggregation of basic types, package the basic types into cocos2d: value, and then combine them with the template container cocos2d: vector and cocos2d: map. Want to know moreMobile Internet tutorialFor more information, log on to the E-mentor Yiyou network.
This article is from the blog, please be sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1555670
Cocos2d-cocos2d: Value instance sharing