Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-13-2010, 01:38 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 2
Espuz is on a distinguished road
Unhappy Switch between OpenGL View and UIKit View

Hello everyone, I'm new on his forum and I hope you can answer my question and help me to solve this problem. I have read many threads on this forum about questions like that but I don't understand several points.

Well, i'm developing a game on iPhone with OpenGL ES. I began my development few months ago using the Xcode template (SDK 2.1) OpenGL ES Application, with one EAGLView and an AppDelegate, etc.

My menu view and game view use the same OGL view with custom "abstract" views and transitions, so I didn't need more views. 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.

I think that the best solution is to have my current OGL View with another UIKit View where I will put the score ranking and do the switching when necessary.

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.

I don't know how can I make a UIViewController of my current EAGLView, attach it to a nib, etc. Also, I don't know how the game works now because the MainWindow.xib doesn't have anything except window and app. delegate.

Yes, I'm very very lost Can anyone help me with this?

Thank you very much.
Espuz is offline   Reply With Quote
Old 02-14-2010, 08:04 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 2
Espuz is on a distinguished road
Talking

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:

Code:
//- (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:

Code:
- (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
Espuz is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
7 members and 392 guests
13dario13, iOS.Lover, jeroenkeij, Leslie80, Wikiboo, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:43 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0