Reputation: 31
Anyone know of any example or codes which i am able to input so that a view which is the menu of my game is able to start the game on clicking start game button? Its like from menu view to the game view.
I had already done up the game just need my menu to link to the game. Thanks alot for any help.
Upvotes: 1
Views: 489
Reputation: 4351
You don't have to use a UINavigationController since you can add sub views to the main window as well.
Check out this tutorial for a good example. https://web.archive.org/web/20100102064245/http://icodeblog.com/2009/03/18/iphone-game-programming-tutorial-part-3-splash-screen/
Upvotes: 0
Reputation: 2592
You can do this in two ways which I know. First is on the click of the button you need to call the view to which you want to navigate as:
[self presentmodalviewcontroller:gameview animated:yes]
This just overlaps the view on another view. gameview
is the view to which you want to navigate, and do remember to make its object by allocation before using the above line.
Another good way is to use uinavigationcontroller
which push and pop the view and is the good practice. Allocate the navigation controller with rootviewcontroller
which is your present view. To navigate just use:
[self.navigationcontoller pushviewcontroller:gameview]
and to pop the view to come back to the previous view you just need to use:
[self.navigationcontroller popviewcontroller animated:yes]
Congrats for completing your game application.
Upvotes: 0
Reputation: 19782
You can use a UINavigationController to manage switching to/from the game and the menu. Alternatively, you can use UIAnimation to fade one in, while the other fades out, or move one view off-screen while the other moves on-screen. What sort of effect were you hoping for?
Upvotes: 0
Reputation: 22116
Assuming that you're not using a game engine, you could use a UINavigationController and just use pushViewController:animated: You could also use an Animation block and addSubview:
These are very elementary principles, how did you manage to finish an entire game without learning about view hierarchies?
Upvotes: 1