我是iPhone编程新手,事实上,任何类型的编程。近一年来,我一直在教自己C,然后是Objective-C,在过去的几个月中,我一直在制作一款iPhone游戏,到目前为止我对此感到非常自豪。从OpenGL视图加载UIView
无论如何,我已经打了一个绊脚石,我一直试图弄清楚一段时间,不能,如果有人能指出我正确的方向,我会非常感激。
基本上,当应用程序启动时,它加载到UIView,这就像一个菜单系统,有“加载游戏”,“查看高分等”选项......当“加载游戏”被按下,一个OpenGL视图被创建并且我的游戏开始播放。当游戏中的宇宙飞船撞向一颗行星时,游戏意味着结束,另一个UIView交换显示高分,并提示重试。我一直试图让这个UIView交换一段时间,但它似乎不工作。代码全部编译正确,没有错误或警告,但是当飞船坠入行星时,什么都不会发生。 OpenGL视图保持为主视图,并且不会加载其他视图。
这里是我的RootViewController的类的代码,drawEAGLView是当“加载游戏”按下调用,当飞船坠毁NEWPAGE被称为:
- (IBAction)drawEAGLView:(id)sender { //This code is called when "Load Game" is pressed in the first UIView.
//This function contains the loading code of the OpenGl view, and seems to work well.
BBSceneController * sceneController = [BBSceneController sharedSceneController];
// make a new input view controller, and save it as an instance variable
BBInputViewController * anInputController = [[BBInputViewController alloc] initWithNibName:nil bundle:nil];
sceneController.inputController = anInputController;
[anInputController release];
// init our main EAGLView with the same bounds as the window
EAGLView * glView = [[EAGLView alloc] initWithFrame:window.bounds];
sceneController.inputController.view = glView;
sceneController.openGLView = glView;
self.view = glView;
[glView release];
glView.alpha = 0.0;
[UIView beginAnimations:@"fadeout" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
// Change any animatable properties here
glView.alpha = 1.0;
[UIView commitAnimations];
// set our view as the first window view
[window addSubview:sceneController.inputController.view];
[window makeKeyAndVisible];
// begin the game.
[sceneController loadScene];
[sceneController startScene];
}
- (void)newPage //This code is run when the spaceship crashes into the planet.
{
NSLog(@"ViewTwoLoaded"); //This is logged in the console, which proves the code is being run.
if(self.viewTwoController == nil)
{
ViewTwoController *viewTwo = [[ViewTwoController alloc]
initWithNibName:@"View2" bundle:[NSBundle mainBundle]]; //View2 is the nib i want to load, but does not load.
self.viewTwoController = viewTwo;
[viewTwo release];
}
[self.navigationController pushViewController:self.viewTwoController animated:YES];
}
我试着用搜索引擎和论坛搜索它很长一段时间,但(可能是因为我不知道确切的使用条款),我找不到任何东西!
我尽量提供尽可能多的信息,任何帮助将非常感谢!
由于提前, 克雷格