进行屏幕触摸设置时候是在layer层之中进行设计
单点触摸:
auto listener = EventListenerTouchOneByOne::create();//声明事件
listener->onTouchBegan = [](Touch* touch,Event* event);
listener->onTouchMoved = [](Touch* touch,Event* event);
listener->onTouchEnded = [](Touch* touch,Event* event);
_eventDispatcher->addEventListenerWithSceneGraph(listener,this);//注册进入列表
根据touch可以获得触摸点(注意坐标的转换)
Directer::getinstance()->converttoGL(touch->getlocationInveiw());
auto target=static_cast<sprite*>(event->getcurrenttarget());
listenner->setswallowtoches(true);
吞并触摸
原文链接:https://www.f2er.com/cocos2dx/341538.html