2

因为到目前为止我使用整个 cocos2d 进行了游戏,并且我第一次使用负责启动游戏场景的 UIViewController 的项目工作,我想知道我该怎么做,因为 appDelegate 是从一个普通的 UIViewController,如何在按钮上设置方法来启动游戏(例如游戏的第一个场景)?我一直在寻找关于这个的例子或讨论,但我没有找到任何东西,我看到的每个例子都是在第一次调用时从 appDelegate 开始游戏场景。

4

1 回答 1

0

只需导入您的 cocos2d layer.h 和 layer.m 文件并从视图控制器调用使用以下代码:-

if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
        [CCDirector setDirectorType:kCCDirectorTypeDefault];


    CCDirector *director = [CCDirector sharedDirector];

    EAGLView *glView = [EAGLView viewWithFrame:[self.view bounds]
    pixelFormat:kEAGLColorFormatRGB565 depthFormat:0];

    [director setOpenGLView:glView];


    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];


    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:YES];

    [self setView:glView];

    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

    [[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]];
于 2013-10-11T12:28:27.957 回答