cocos2d-x 3.2 实现模态对话框

前端之家收集整理的这篇文章主要介绍了cocos2d-x 3.2 实现模态对话框前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

使用Layer实现对话框,在init函数添加以下代码

auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [=](Touch *touch,Event *event)
{
    return true;
};
listener->setSwallowTouches(true);
_eventDispatcher->addEventListenerWithSceneGraPHPriority(listener,this);
listener->setSwallowTouches(true);不向下传递触摸,比如有两个Layer A和B,A在B上面,触摸A时,事件就不会传递到B,从而实现模态对话框 listener->setSwallowTouches(false);向下传递触摸事件 原文链接:https://www.f2er.com/cocos2dx/347059.html

猜你在找的Cocos2d-x相关文章