从UIKit / Cocoa-Touch运行Cocos2D场景,但场景未接收到触摸输入

时间:2013-01-11 23:16:43

标签: uiviewcontroller cocos2d-iphone uikit

想出如何让UIKit和Cocos2D协同工作。我正在从UITableViewCell启动我的游戏场景(应该使用Cocos2D)。问题是,运行此方法后......

// MainViewController.h

MainViewController : UIViewController <CCDirectorDelegate,
                                      UITableViewDelegate, 
                                      UITableViewDataSource, 
                                      GKGameCenterControllerDelegate>

// MainViewController.m

-(void)launchGamePlay {
    [self.tableView removeFromSuperview];

    // ... also removing buttons and other assets with removeFromSuperview

    [mainNavBar removeFromSuperview];
    [underView removeFromSuperview];

    CCTransitionRotoZoom *transition = [CCTransitionRotoZoom transitionWithDuration:1.0 scene:[CCGamePlayLayer node]];
    [[CCDirector sharedDirector] runWithScene:transition];
}

...我无法在呈现的CCGamePlayLayer上接收触摸输入。我已经尝试用zOrders搞乱呈现视图控制器和呈现的cocos场景无济于事。我做错了什么?

1 个答案:

答案 0 :(得分:0)

您的MainViewController很可能正在接收触摸输入。

覆盖MainViewController中的各种touchesBegan / Moved / Ended方法并将它们转发到cocos2d的视图:

[[CCDirector sharedDirector].view touchesBegan:touches event:event];