我是Cocos2Dx的新手。我正在尝试创建一个有3-4个模式的游戏。我已经使用UIKit (特定于iOS的代码)创建了菜单。现在我需要调用相应的CCScene类。我已经分别实现了它们。但我不知道如何呈现它们。
在button1 press上,我执行以下操作:
// Add the view controller's view to the window and display.
_window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
// Init the EAGLView
EAGLView *__glView = [EAGLView viewWithFrame: [_window bounds]
pixelFormat: kEAGLColorFormatRGB565
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0];
[__glView setMultipleTouchEnabled:YES];
// Use RootViewController manage EAGLView
_viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
_viewController.wantsFullScreenLayout = YES;
_viewController.view = __glView;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[_window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[_window setRootViewController:_viewController];
}
[_window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:true];
cocos2d::CCApplication::sharedApplication()->run();这个轮流调用AppDelegate.cpp,并像这样呈现游戏的模式1:
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// turn on display FPS
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = ClassicModeLayer::scene();
// run
pDirector->runWithScene(pScene);这里的模式一被称为ClassicMode。现在如何按button2并调用另一个用于街机模式或其他模式的CCScene?如何将按钮按下事件传递给AppDelegate.cpp
发布于 2014-05-28 17:10:51
你为什么不添加cocos2dx的模式选择屏幕,也就是CCScene本身,
只需先添加模式选择场景,然后根据选择的模式加载场景。
https://stackoverflow.com/questions/23907242
复制相似问题