Cocos2dx 3.0 transition article (): common use of ValueMap, cocos2dxvaluemap
When they arrived in Xiamen over the weekend, they gathered together to get together. At night, a group of people went to the competition and prepared to get drunk. My friend suddenly said that there was no bathroom... Nima. At that time, we were not happy: Drinking beer for five or six hours, without a bathroom. Who are you planning to throw? If you do not want to change one, you must make a careful choice this time. Finally, I saw a seemingly authentic dashboard. I subconsciously dialed my hair and walked to the front-end MM and asked softly: you guys... do you have a restroom?
The voice is deep and sexy, with a slight sadness in the tone.
The front-end MM opened his eyes and said after a while: Is the bathroom? Yes!
----------------------------
Okay. Next I will continue to talk about some other issues.
Let's talk about ValueMap this time. Don't ask me what this is. Let's check it out in Value. h!Of course, in this age when Google was "dead", it is not recommended that you go to Baidu, because Baidu cannot find words related to ValueMap at all. If you don't believe it, try it.
ValueMap functions the same as ValueVector. It can only store data-type elements.. For more information, see some common usage:
1. Add an element to ValueMap:
Value a(10);ValueMap star_map;star_map.insert(map<std::string,Value>::value_type("star",a));The code above puts variable a of the Value type (actually an integer) into the ValueMap container. Here I use the insert method used in the map container.
The key of a in the ValueMap container is "star ".
However, this method is very troublesome!
The map <std: string, Value >:: value_type is a newly created pair object, which is directly inserted into the map container. Keep in mind the synonyms of the value_types pair <const K, V> type. K is the key type, and V is the type of the value associated with the key.
The arguments passed to insert are rather clumsy and can be simplified in two ways:
1) Use make_pair
star_map.insert(make_pair("star",a));
2) use typedef
typedef map<std::string,Value>::value_type valType;star_map.insert(valType("star",a));
Of course, the above method is still a little troublesome and not so fast at all. Do you have any direct solutions? Of course:
star_map["star"] = a;
In this way, "star" is the key name, and "a" is the key value.
Is it convenient ?! Fast! Accurate! Sorry!
2. Read the elements in ValueMap
Let's talk about the above. Read it from star_map. How can I find it in star_map? It is easy to find the key corresponding to.
Value a = star_map["star"];
In this way, a is taken out, which is easy. We all know that a is actually an integer, so we can directly convert it into an integer when getting a. The Code is as follows:
int a = star_map["star"].asInt();
OK;
Let's talk about this. For more details, refer to the previous ValueVectoR: http://blog.csdn.net/star530/article/details/37834689
Respect Original, reprinted please indicate Source: http://blog.csdn.net/star530/article/details/38025749
Cocos2dx-30-rc1 compilation APK Error
The deserialization of framework-res.apk requires the original file that has not been moved,
The system packages are actually compiled twice.
You decompile the file first, and then do not modify anything. Compile the file directly. If an error is reported, the file is passive.