标签:listener target create touch
进行屏幕触摸设置时候是在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());
根据Event可以获取当前注册对象
auto target=static_cast<sprite*>(event->getcurrenttarget());
listenner->setswallowtoches(true);
吞并触摸
标签:listener target create touch
原文地址:http://cxdbk.blog.51cto.com/8808491/1690211