在cocos2d中为游戏开发创建“开发人员屏幕”

时间:2011-04-29 16:39:18

标签: iphone ios cocos2d-iphone

我目前正在使用Cocos2D API在iPhone上开发游戏。进行得顺利。我遇到的一个问题是,每次我想要更改变量时都必须重新编译。这非常繁琐,特别是现在我正在调整游戏玩法。

某种开发者控制台屏幕是否有任何实现?我的意思是:我希望有一种我加载的游戏画面,其中包含我在游戏画面中注册的变量列表(带滚动条)。我希望能够在现场修改这些变量。

我记得有一个关于WWDC活动的演示文稿,他们在ipad上展示了这样一个屏幕。开发人员只需按一个按钮,游戏屏幕就会变成像屏幕一样的开发者控制台。我知道这个演示文稿与Cocos2D无关,但是,如果它已经以某种形式或形式存在,我很乐意重复使用这些代码而不是自己编写代码。

虽然如果我必须自己写,我真的不知道从哪里开始。所以任何帮助都会受到赞赏。

THX!

2 个答案:

答案 0 :(得分:4)

去年Apple的WWDC上(我相信)Graeme Devine对如何实现这样的开发者控制台提出了一些建议(查看iTunes大学的视频)。 example code of WWDC 2010 (232 MB)中包含一个名为游戏机的示例。为方便起见,我还从DropBox added a link (57 kb) GameConsole.zip

答案 1 :(得分:0)

这是一个严重回溯的回复,但我们为Mega Run实施了一个开发人员控制台,以测试各个阶段并在运行时修改播放器属性。实现是在游戏中的任何一点点击屏幕的左上角以调出控制台。从那里你可以修改你的需求。实现的框架是覆盖EAGLView并自己处理touchesBegan触控回调。这是实施......

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  const CGFloat DEV_DASHBOARD_ENABLE_TOUCH_AREA = 20.0f;

  for (UITouch* t in touches)
  {
    CGPoint pt = [t locationInView:self];

        if (pt.x < DEV_DASHBOARD_ENABLE_TOUCH_AREA && pt.y < DEV_DASHBOARD_ENABLE_TOUCH_AREA)
        {
            ToolSelectorContainer* editorViewController = [[ToolSelectorContainer alloc] initWithNibName:@"ToolSelectorContainer" bundle:nil]; 

            if (editorViewController != nil)
            {
                CCScene* g = [CCDirector sharedDirector].runningScene;

                // Pause the game if we're in it playing
                //
                if ([g isKindOfClass:[Game class]])
                    [((Game *)g) menuPause];

                [[GSGCocos2d sharedInstance].navigationController pushViewController:editorViewController animated:YES];
                [editorViewController release];

                break;
            }
        }
    }

    #endif

    [super touchesBegan:touches withEvent:event];
}

ifdef用于不为生产版本编译此代码。