【cocos2d-x 3.0】瞬间明白std::bind与CC_CALLBACK_N
来源:互联网 发布:微信造假软件 编辑:程序博客网 时间:2024/05/18 00:23
// 某个函数定义成这样int fun(int param1, char* param2, long param3) ...// 绑定函数指针,固定第三参数为33333auto callback = std::bind(&fun, std::placeholders::_1, std::placeholders::_2, 33333); // 作用等同于fun(11111, "22222", 33333);callback(11111, "22222");若回调函数为某个Class的非static成员对象,则需要传入this指针,也就是这样写
auto callback = std::bind(&A::fun, this, std::placeholders::_1, std::placeholders::_2, 33333);也就等于下面这么写
auto callback = CC_CALLBACK_2(A::fun, this, 33333)
*注:
CC_CALLBACK_N中的“N”
也就是调用callback时要传入的参数个数(或者说通过callback调用fun时,非固定值的参数个数)
copyright by
scarlet.MP5
0 0
- 【cocos2d-x 3.0】瞬间明白std::bind与CC_CALLBACK_N
- cocos2dx 3.0 之 用std::bind替换CC_CALLBACK_N
- cocos2d-x 3.3 CC_CALLBACK_0 std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- cocos2d-x-3.0学习笔记之std::function、std::bind
- 【很nice的一篇文章】c++11特性与cocos2d-x 3.0之std::bind与std::function
- cocos2d-x CC_CALLBACK和std::bind 的关系
- Cocos2d-x3.0-std::bind与CC_CALLBACK不得不说的故事
- std::bind与std::function
- Cocos2dx 3.0 std::bind与CC_CALLBACK
- Cocos2d-x 3.0 多线程 std::thread
- LeetCode 008 String to Integer (atoi)
- Python 中的文件读写(二)
- UI 设计
- 控件指针 与数字
- 中文分词选取-依概率选取
- 【cocos2d-x 3.0】瞬间明白std::bind与CC_CALLBACK_N
- MTC及Testin错误,原因分享
- 华为C8813精简三网破解刷机包 基于B177最新版制作 自带归属地
- 解读C的声明(用英语来阅读)
- 练习题(4) -- 一道简单而有有趣的题目
- BUCT OJ 2264: The Unsolvable Problem
- mysql使用sql导入数据中文乱码问题
- web.py 0.3 新手指南 - db.select 查询
- JavaScript中获取事件源的小例子