Changing the current view controller?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Changing the current view controller?

Post by ibly31 »

I'm using OpenGL ES and the file I'm currently editing is called EAGLView.h/m ... I think it's a viewcontroller, not sure though. I was thinking about how to do a game with it and I started designing the title page. Then I realized... how would I draw depending on what section of the game I'm on? (title, menu, actual game, ending etc...). Then I thought maybe I'd have to switch the controller of the view and set up a whole new EAGLView2.h/m and do that. Is this the best way? If so, then how do you do it?

Basically my Classes folder will be:

EAGLViewTitle.h
EAGLViewTitle.m
EAGLViewMenu.h
EAGLViewMenu.m

Any help?
Last edited by ibly31 on Sat Aug 01, 2009 4:45 pm, edited 1 time in total.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Innerscope
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:

Re: Changing the current view conntroller?

Post by Innerscope »

ibly31 wrote:I'm using OpenGL ES and the file I'm currently editing is called EAGLView.h/m ... I think it's a viewcontroller, not sure though. I was thinking about how to do a game with it and I started designing the title page. Then I realized... how would I draw depending on what section of the game I'm on? (title, menu, actual game, ending etc...). Then I thought maybe I'd have to switch the controller of the view and set up a whole new EAGLView2.h/m and do that. Is this the best way? If so, then how do you do it?

Basically my Classes folder will be:

EAGLViewTitle.h
EAGLViewTitle.m
EAGLViewMenu.h
EAGLViewMenu.m

Any help?
Just use "states" or (depending on how complex your game is) a "screen" class of sorts. Don't change the viewer, just change the code sent to the viewer.
You can still set it up like:
Title.h
Title.m
Menu.h
Menu.m
Within those have your draw code, mouse/keyboard input code, etc.
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Changing the current view conntroller?

Post by ibly31 »

I don't understand... sorry, I'm new to iphone programming. But I have a single EAGLView.m view controller that I'm running with a "drawView" method... how do I tell the program to start running EAGLViewTitle.h/m or EAGLViewMenu.h/m?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Innerscope
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:

Re: Changing the current view conntroller?

Post by Innerscope »

ibly31 wrote:I don't understand... sorry, I'm new to iphone programming. But I have a single EAGLView.m view controller that I'm running with a "drawView" method... how do I tell the program to start running EAGLViewTitle.h/m or EAGLViewMenu.h/m?
This isn't all that different from programming for a PC. You'll have to "#import" your files to access their methods. Also the EAGLView is the context you draw into, so you shouldn't have multiple EAGLViews. That's what I was trying to say in my previous post. Other than that, you'll have to post some code if you want more specific help. I'm not an expert (I'm learning this stuff too), but I'll try to help.
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Changing the current view conntroller?

Post by ibly31 »

Okay, I guess I understand somewhat. So I could have a menu() function defined in Menu.h and implemented in Menu.m, and in the main EAGLView class I could call it? I'm still kind of confused though, my Menu() function would have pretty much all the same code my EAGLView stuff has... a setupView: and drawView: function... In case you are unfamiliar with OpenGL ES projects, they have a drawView: function called every frame, and thats all I can really edit... should I just have a bunch of if statements like this:

if(current thing is splash screen)
splash();
if(current = menu)
menu();


and each of thoe will display what i want? and those will be defined in the menu.h and menu.m?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Changing the current view conntroller?

Post by ibly31 »

Bump, is that correct?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Innerscope
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:

Re: Changing the current view conntroller?

Post by Innerscope »

ibly31 wrote:Okay, I guess I understand somewhat. So I could have a menu() function defined in Menu.h and implemented in Menu.m, and in the main EAGLView class I could call it? I'm still kind of confused though, my Menu() function would have pretty much all the same code my EAGLView stuff has... a setupView: and drawView: function... In case you are unfamiliar with OpenGL ES projects, they have a drawView: function called every frame, and thats all I can really edit... should I just have a bunch of if statements like this:

if(current thing is splash screen)
splash();
if(current = menu)
menu();


and each of thoe will display what i want? and those will be defined in the menu.h and menu.m?
ibly31 wrote:Bump, is that correct?
Sorry, I went camping and I just got back today. It also happens to be my Birthday so I'm going to make this short. I've dabbled in OpenGL ES, nothing too serious, but I am familiar with the basic structure. Like you've stated: SetupView (depending on implementation) should really only be called once to set up the viewing context. DrawView will be called multiple times. It appears like you get the gist of what I was saying though.
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Changing the current view conntroller?

Post by dandymcgee »

[offtopic]
@Innerscope:
Image
[/offtopic]
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
imran.hoshimi
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 12
Joined: Mon Dec 01, 2008 4:57 am
Current Project: Nothing. :(
Favorite Gaming Platforms: PC, XBox360, PS2, SNES and almost all of them.
Programming Language of Choice: C/C++
Location: Karachi, Pakistan.
Contact:

Re: Changing the current view conntroller?

Post by imran.hoshimi »

Take a look at this blog ->
http://www.71sqaured.co.uk

The guy has a whole bunch of video tutorials dealing with game programming on the iPhone. From texture mapping to tiling and what not. He discusses everything in a very simple way.
User avatar
Innerscope
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:

Re: Changing the current view conntroller?

Post by Innerscope »

imran.hoshimi wrote:Take a look at this blog ->
http://www.71sqaured.co.uk

The guy has a whole bunch of video tutorials dealing with game programming on the iPhone. From texture mapping to tiling and what not. He discusses everything in a very simple way.
should be http://www.71squared.co.uk/
Interesting blog though, nice find.

And thanks for the birthday comment Dandymcgee :)
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
Post Reply