我在init 中用了:
this->setTouchEnabled(true);
然后我新建一个函数:
void HelloWorld::TouchesEnded(SetpTouches, EventpEvent)
{
CCTouch* touch = (CCTouch*)pTouches->anyObject();//取出一个点
CCPoint locInView = touch->getLocationInView();//得到这个点的位置 UI坐标系的位置点
CCPoint loc = Director::sharedDirector()->convertToGL(locInView);//通过Director将UI坐标系转换成cocos坐标系
}
但是我点击屏幕,根本无法进入到这个函数中呀,我看的是2.2.6的教程~
不过我用的是 3.7的 cocos2d-x~
我c++也是在同步学习中~ 求指导啊~
如何在能实现实现点击触发事件呀~~