cocos2d 模态窗口与 CCLayer

发布于 2024-12-27 04:50:45 字数 352 浏览 2 评论 0原文

尝试用CCLayer实现模态窗口。我的模态视图层被添加为另一个层的子层。

在我的模态视图层上,我添加了方法(启用触摸):

-(void) registerWithTouchDispatcher
{
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    return YES;
}

为什么模态视图层不吞没我的触摸?

Trying to implement a modal window with CCLayer. My modal view layer is added as a child of another layer.

On my modal view layer I've added methods(the touch is enabled):

-(void) registerWithTouchDispatcher
{
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    return YES;
}

Why the modal view layer it doesn't swallos my touches?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2025-01-03 04:50:45

尝试将优先级设置为-129。菜单具有最低优先级(kCCMenuTouchPriority = -128)。只需尝试以下代码:

[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:-129 swallowsTouches:YES];

try to set priority to -129. Menu have lowest priority (kCCMenuTouchPriority = -128). Just try this code:

[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:-129 swallowsTouches:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文