0

弄清楚如何让 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 上接收触摸输入。我已经尝试在呈现视图控制器和呈现的 cocos 场景中使用 zOrders,但无济于事。我究竟做错了什么?

4

1 回答 1

0

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

覆盖MainViewController中的各种touchesBegan/Moved/Ended方法,转发给cocos2d的视图:

[[CCDirector sharedDirector].view touchesBegan:touches event:event];
于 2013-01-11T23:22:14.733 回答