autoaction3=TargetedAction::createthis,CallFunc::createCC_CALLBACK_0Node:
佚名通过本文主要向大家介绍了autoaction3=TargetedAction::createthis,CallFunc::createCC_CALLBACK_0Node:等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: auto action3 = TargetedAction::createthis, CallFunc::createCC_CALLBACK_0Node:
描述:
解决方案1:
这时得到的func就相当与func(int i, int j = 10),用的时候可以用func(15),
描述:
auto action3 = TargetedAction::create(this, CallFunc::create(CC_CALLBACK_0(Node::setVisible, this, false)));
可以实现隐藏,为什么CC_CALLBACK_0能够携带参数,而不是使用CC_CALLBACK_1呢??
解决方案1:
CC_CALLBACK_0 的0不是代表没有参数的意思,而是表示函数绑定第0个参数后面的值。
举个例子:
int add (int i, int j){
return i+j;
}
auto func = CC_CALLLBACK_1(add, this, 10);
这时得到的func就相当与func(int i, int j = 10),用的时候可以用func(15),
cout << func(15) << endl; // 结果是15 + 10 = 25,即cout << 25