Cc_callback_1,cc_callback_2,cc_callback_3
These are the Std::bind macros, the digital three-in-one mainly represents the number of positions to occupy, but also the number of parameters passed in the future.
New callbacks based on C++11
#define CC_CALLBACK_0 (__selector__,__target__, ...) std::bind (&__selector__,__target__, # #__VA_ARGS__)
#define CC_CALLBACK_1 (__selector__,__target__, ...) std::bind (&__selector__,__target__, std::p laceholders::_1, # #__VA_ARGS__)
#define CC_CALLBACK_2 (__selector__,__target__, ...) std::bind (&__selector__,__target__, std::p laceholders::_1, std::p laceholders::_2, # #__VA_ARGS__)
#define CC_CALLBACK_3 (__selector__,__target__, ...) std::bind (&__selector__,__target__, std::p laceholders::_1, std::p laceholders::_2, std::p laceholders::_3 # #__VA_ARGS__)
The corresponding std::bind has several placeholders for std::p laceholders::_1,std::p laceholders::_2,std::p laceholders::_3, and so on, these placeholders are the ones that we're calling specific functions (&__ SELECTOR__) need to pass the parameters, White is to tell us the target &__selector__ in front of the number of parameters need to be passed, cc_callback_2 (__selector__,__target__, ...) Here's the ... It is also possible to pass in parameters, but this parameter cannot replace the placeholder parameter, and the placeholder parameter can only be passed in the call, where the parameter is the value of the parameter after the position parameter is assigned a default value.
Examples Show
Helloworld::sayname (name1, name2, Name3, Name4, Name5) {
}
Cc_callback_3 (Self::sayname, Self, "Xiao Ming", "Xiao Li") This sentence is Std::bind (&__selector__,__target__, std::p laceholders::_1, std::p laceholders::_2, std::p laceholders::_3, "Xiao Ming", "Xiao Li")
Assume
Auto Delegatefucname = Std::bind (&__selector__,__target__, std::p laceholders::_1, std::p laceholders::_2, std:: Placeholders::_3, "Xiao Ming", "Xiao Li")
Delegatefucname (...) This time ... Is the value of the 3 placeholders to be passed, Delegatefucname ("Snow", "Small Wind", "Floret")
The end result is the placeholder pass parameter ("Snow", "Small Wind", "Floret") +cc_callback_3 subsequent parameters ("Xiao Ming", "Xiao Li") complete the parameters of the objective function sayname
Cocos Advanced Tutorials (5) Tips for using the Cc_callback_x series