error C2664: “void std::_Pmf_wrap<void (__thiscall cocos2d::Layer::* )(const std::vector<cocos2d::To
2015-03-28 22:27
741 查看
使用vs2013编写cocos2dx的代码:
_touchListener = EventListenerTouchOneByOne::create();
_touchListener->setSwallowTouches(true);
_touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
_touchListener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchesMoved, this);
_touchListener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
_touchListener->onTouchCancelled = CC_CALLBACK_2(HelloWorld::onTouchCancelled, this);
结果编译时报如下错误
error C2664: “void std::_Pmf_wrap<void (__thiscall cocos2d::Layer::* )(const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &,cocos2d::Event *),void,cocos2d::Layer,const std::vector<_Ty,std::allocator<_Ty>> &,cocos2d::Event *>::operator ()(_Farg0 &,const
std::vector<_Ty,std::allocator<_Ty>> &,cocos2d::Event *) const”: 无法将参数 2 从“cocos2d::Touch *”转换为“const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &”
d:\program files (x86)\microsoft visual studio 12.0\vc\include\functional
1149 1
GameCenter
从错误的意思看是说不能将cocos2d::Touch *转换为const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &
最终发现是因为写错了函数,_touchListener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchesMoved, this);
这里将HelloWorld::onTouchMoved错写成了HelloWorld::onTouchesMoved,导致函数不匹配。
_touchListener = EventListenerTouchOneByOne::create();
_touchListener->setSwallowTouches(true);
_touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
_touchListener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchesMoved, this);
_touchListener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
_touchListener->onTouchCancelled = CC_CALLBACK_2(HelloWorld::onTouchCancelled, this);
结果编译时报如下错误
error C2664: “void std::_Pmf_wrap<void (__thiscall cocos2d::Layer::* )(const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &,cocos2d::Event *),void,cocos2d::Layer,const std::vector<_Ty,std::allocator<_Ty>> &,cocos2d::Event *>::operator ()(_Farg0 &,const
std::vector<_Ty,std::allocator<_Ty>> &,cocos2d::Event *) const”: 无法将参数 2 从“cocos2d::Touch *”转换为“const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &”
d:\program files (x86)\microsoft visual studio 12.0\vc\include\functional
1149 1
GameCenter
从错误的意思看是说不能将cocos2d::Touch *转换为const std::vector<cocos2d::Touch *,std::allocator<_Ty>> &
最终发现是因为写错了函数,_touchListener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchesMoved, this);
这里将HelloWorld::onTouchMoved错写成了HelloWorld::onTouchesMoved,导致函数不匹配。
相关文章推荐
- error C2664: “void std::_Pmf_wrap<void (__thiscall cocos2d::Layer::* )(const std::vector<cocos2d::To
- 实战c++中的string系列--std:vector<char> 和std:string相互转换(vector to stringstream)
- 实战c++中的string系列--std:vector<char> 和std:string相互转换(vector to stringstream)
- xcode编译错误"std::__1::__vector_base_common<true>::__throw_length_error() const"
- C++编译出现binding ‘const string {aka const std::__cxx11::basic_string<char>}’ to reference of type ‘std
- C++ error: passing 'const std::map<>]' discards qualifiers或pass-by-reference-to-const-map导致的“discards qualifiers”
- convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
- 不能将参数 1 从“int”转换为“std::_Vector_const_iterator<_Myvec>”(VS2010 )
- 去除Warning C4251 “class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class
- 实战c++中的string系列--std:vector<char> 和std:string相互转换(vector to stringstream)
- error C2664: “void std::basic_fstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,
- 实战c++中的vector系列--对vector<自定义类>使用std::find 和 std::find_if 算法
- Assigning to 'id<QMapViewDelegate>" from incompatible type "view control * const_strong"
- c++ const char* to const void
- std::vector<bool>
- Cocos2d-x中Vector<T>容器以及实例介绍
- xcode c11 居然报错 std::function<void(CCNode*,CCObject*)> __callback;
- Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))
- Cocos2d-x3.0模版容器详解之一:cocos2d::Vector<T>
- c++ error: reference to 'plus' is ambiguous ; template<class _Tp> struct std::plus