关于点击事件

  • 本帖最后由 Long 于 2012-9-19 17:45 编辑 *

在vs2010中,我用的是2.0版本的cocos2dx,在HelloWorld.h声明virtual void ccTouchesBegan(CCSet *pTouches,CCEvent *pEvent);
在HelloWorld.cpp中实现
void HelloWorld::ccTouchesBegan(CCSet *pTouches,CCEvent *pEvent)
{
CCLog(“用户点击!~”);
}

为什么打印不出语句?还有如何获得点击的坐标?

this->setTouchEnabled(true);

void UIBattleLayer::registerWithTouchDispatcher(){
//使用int最小值做最高优先级,并且吞掉事件true
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,
numeric_limits ::max(),
false);
CCLayer::registerWithTouchDispatcher();
}

:slight_smile:

坐标的话

CCPoint location = pTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);

问个有点深度的问题,ccTouchesBegan方法的第一个参数可以用CCSet *pTouch,也可以用CCTouch *pTouch,这两者有什么不同吗?:blush: