带有CCLayer的cocos2d模态窗口

时间:2012-01-17 08:50:29

标签: objective-c cocoa-touch cocos2d-iphone modal-dialog

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

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

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

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

为什么模态视图图层不会触及我的触摸?

1 个答案:

答案 0 :(得分:2)

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

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