开发者

Creating a "developer screen" for game development in cocos2d

开发者 https://www.devze.com 2023-03-01 09:36 出处:网络
I\'m currently developing a game on iPhone using the Cocos2D API. It\'s going well. One issue I\'m having though is that I have to recompile each time I want to change my variables. This is very tedio

I'm currently developing a game on iPhone using the Cocos2D API. It's going well. One issue I'm having though is that I have to recompile each time I want to change my variables. This is very tedious, especially now that I am tweaking gameplay.

Is there any implementation for a sort of developer console screen? What I mean is: I want to have a type of game screen that I load, that contains a list of variables that I register to the game screen(with scroller). And I want to be able to modify these variables on the spot.

I remember there being a presentation on a WWDC event in which they showed such a screen on an ipad. The developer would just press a button and the gamescreen would change to a developer console like screen. I know this presentation had nothing to do with Cocos2D开发者_C百科, but still, if this already exists in some shape or form, I would love to re-use this code instead of writing it on my own.

Though if I had to write it on my own, I wouldn't really know where to start. So any help there would be appreciated as well.

Thx!


It was (I believe) Graeme Devine at Apple's WWDC last year who had some suggestions on how to implement such a developer console (check the video on iTunes University). An example called Game Console is included with the example code of WWDC 2010 (232 MB). I've also added a link (57 kb) to GameConsole.zip from DropBox, for convenience.


This is a seriously backdated reply but we implemented a developer console for Mega Run to test out various stages and modify player properties at run time. Implementation was to tap in the top left corner of the screen at any point in the game to bring up the console. From there you could modify to your needs. The skeleton of the implementation was to override EAGLView and handle the touchesBegan touch callback yourself. Here is the implementation...

-(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 is used to not compile this code for production builds.

0

精彩评论

暂无评论...
验证码 换一张
取 消