大佬教程收集整理的这篇文章主要介绍了cocos2dx[3.2](11)——新回调函数std::bind,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1
2
3
4
5
6
7
|
* 函数动作
* -CallFunc
* -CallFuncN
* -CallFuncND与CallFuncO已被遗弃,请使用CallFuncN替代
*/
//2.x版本
CCCallFuncN::create(
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,callfuncN_SELEctor(HelloWorld::callBACk1));
CCCallFuncND::create(
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,callfuncND_SELEctor(HelloWorld::callBACk2),(
void
*)10);
//回调函数
//3.x版本
//使用CC_CALLBACK_*
CallFunc::create(CC_CALLBACK_0(HelloWorld::callBACk0,monospace!important; font-size:1em!important; min-height:inherit!important">));
CallFuncN::create(CC_CALLBACK_1(HelloWorld::callBACk1,monospace!important; font-size:1em!important; min-height:inherit!important">));
//使用std::bind
//其中sprite为执行动作的精灵
CallFunc::create(std::bind(&HelloWorld::callBACk0,monospace!important; font-size:1em!important; min-height:inherit!important">));
//回调函数
18
//callBACk0
));
//callBACk1
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,std::placeholders::_1));
//callBACk2
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,0.5));
//回调函数
//可自定义参数类型float
2.2、菜单项回调menu_SELEctor
15
"1.png"
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
"2.png"
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,menu_SELEctor(HelloWorld::callBACk));
//3.x版本
//CC_CALLBACK_1
));
//std::bind
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,std::bind(&HelloWorld::callBACk1,std::placeholders::_1));
2.3、触控事件回调
14
auto
touchLisner=EventListenerTouchOneByOne::create();
//绑定事件
touchLisner->onTouchBegan=CC_CALLBACK_2(HelloWorld::onTouchBegan,monospace!important; font-size:1em!important; min-height:inherit!important">);
touchLisner->onTouchMoved=CC_CALLBACK_2(HelloWorld::onTouchMoved,monospace!important; font-size:1em!important; min-height:inherit!important">);
touchLisner->onTouchEnded=CC_CALLBACK_2(HelloWorld::onTouchEnded,monospace!important; font-size:1em!important; min-height:inherit!important">);
//回调函数
3、未变更的回调函数
7
//回调函数
3.2、按钮事件回调cccontrol_SELEctor
7
button->addTargetWithActionForControlEvents(
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,cccontrol_SELEctor(HelloWorld::callBACk),Control::EventType::TOUCH_DOWN);
4、扩展回调函数
22
"CloseNormal.png"
);
sprite->setPosition(Vec2(visibleSize/2));
->addChild(spritE);
itemImage=MenuItemImage::create(
String" style="padding:0px!important; margin:0px!important; border:0px!important; bottom:auto!important; float:none!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
std::bind(&HelloWorld::callBACk4,10,monospace!important; font-size:1em!important; min-height:inherit!important">itemImage->setPosition(Vec2(visibleSize/4));
pMenu=Menu::create(itemImage,null);
pMenu->setPosition(Vec2::ZERO);
->addChild(pMenu);
//回调函数
HelloWorld::callBACk4(Node*sender,Sprite*bg,monospace!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:gray!important">int
a,monospace!important; font-size:1em!important; min-height:inherit!important">b)
bg->setScale(a*b);
}
本文出自 “夏天的风” 博客,请务必保留此出处http://www.voidcn.com/article/p-kiicpnup-wx.html
大佬总结
以上是大佬教程为你收集整理的cocos2dx[3.2](11)——新回调函数std::bind全部内容,希望文章能够帮你解决cocos2dx[3.2](11)——新回调函数std::bind所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。