我新建了一个cocos2dx工程,在HelloWorldScene的init方法中加入如下代码:
_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);
_eventDispatcher->addEventListenerWithFixedPriority(_touchListener, 1);
然后编译的时候总是报如下错误,使用的是vs2013.
错误 1 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