在一个图层里面添加了一个Menu, 但是不想直接用回调函数,因为想通过触摸滑动实现特殊效果
所以init 函数后
setTouchEnabled(true);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch, Event *event) {
bool bIsTouched= m_pNodeSureBtn->onTouchBegan(touch, event);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
bIsTouched 永远是flase,难道menu不能响应触摸事件吗>>>
然后使用
setTouchEnabled(true);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch, Event *event) {
bool bIsTouched= m_pNodeSureBtn->getBoundBox().containsPoint(touch->getLocation());
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
这样稍微偏移menu一点的地方触摸就会响应,但是在menu上面点击无效果 求解 求解
所以init 函数后
setTouchEnabled(true);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch, Event *event) {
bool bIsTouched= m_pNodeSureBtn->onTouchBegan(touch, event);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
bIsTouched 永远是flase,难道menu不能响应触摸事件吗>>>
然后使用
setTouchEnabled(true);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch, Event *event) {
bool bIsTouched= m_pNodeSureBtn->getBoundBox().containsPoint(touch->getLocation());
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
这样稍微偏移menu一点的地方触摸就会响应,但是在menu上面点击无效果 求解 求解