views:

849

answers:

3

Hello everyone, this is my question.

I'm developing a game on iPhone with OpenGL ES. I began my development using the Xcode template OpenGL ES Application, with one EAGLView, etc.

My menu view and game view use the same OGL view but now I want to add score ranking so I need a keyboard and a text field to write name, and some labels or a table view to show ranking.

UPDATE: well, I think that the best solution is to have my current glView with another UIKit View where I will put the score ranking and do the switching.

I have the Apress book Beginning iPhone Development and I follow the chapter about multiple views. I take the point of switching between two UIViewController but when I'm going to make changes in my game... glView is not a UIViewController, it's a UIView, so I'm lost.

Can anyone help me with this? :-(

Thank you very much.

A: 

You can simply push a normal viewcontroller on top of the OpenGL view(controller) to show a dialog for the score ranking. For example with presentModalViewController:animated:.

St3fan
I make an update and I have a new question. I think what you said is what I'm looking for but, can you explain it a bit more? Thanks.
Espuz
+2  A: 

Well, I think I solved the problem, so I share the solution with you.

I started from the multiple views example from the book: three xib (main window and two views we switch), the app. delegate, two view controller for each view and a root view controller which switch between our views.

I added the EAGLView class and renderer to this project and changed the initWithCoder method on EAGLView to initWithFrame:

//- (id) initWithCoder:(NSCoder*)coder
- (id)initWithFrame:(CGRect)frame
{    
    if ((self = [super initWithFrame:frame])) {
    // The same we had.

Then, in my root view controller I have added an IBAction when I tap a button:

- (IBAction)drawEAGLView:(id)sender {
    CGRect rect = [[UIScreen mainScreen] applicationFrame];
    glView = [[EAGLView alloc] initWithFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];
    self.view = glView;
    [glView startAnimation];
}

And that's all. Very simple and it works well. Maybe it needs some optimization but this is a good start point.

So, I can make now my score ranking :D

Espuz
Note that you are leaking the glView every time -drawEAGLView: is called. You need to release it after you assign it to self.view.
Brad Larson
A: 

Work great !!

But how to go back from glview to viewcontroller ???

Any help plzz !!??

Alex