Page 1 of 1
Changing the current view controller?
Posted: Sat Jul 18, 2009 3:20 pm
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?
Re: Changing the current view conntroller?
Posted: Sat Jul 18, 2009 3:40 pm
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.
Re: Changing the current view conntroller?
Posted: Sat Jul 18, 2009 10:01 pm
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?
Re: Changing the current view conntroller?
Posted: Sat Jul 18, 2009 11:07 pm
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.
Re: Changing the current view conntroller?
Posted: Sun Jul 19, 2009 3:03 pm
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?
Re: Changing the current view conntroller?
Posted: Tue Jul 21, 2009 10:46 am
by ibly31
Bump, is that correct?
Re: Changing the current view conntroller?
Posted: Wed Jul 22, 2009 9:19 pm
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.
Re: Changing the current view conntroller?
Posted: Wed Jul 22, 2009 10:34 pm
by dandymcgee
[offtopic]
@Innerscope:
[/offtopic]
Re: Changing the current view conntroller?
Posted: Sat Aug 01, 2009 4:22 am
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.
Re: Changing the current view conntroller?
Posted: Sat Aug 01, 2009 11:33 am
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