开发者

Simple menu in iPhone game

I am developing a puzzle game for the iPhone using core graphics implementing drawrect in a single UIView.

I would like to add a menu which is opened from a UIButton event handler.

I am not sure if I should do this via code e.g. have a menuopen flag and adjust the drawing routines and tap event handlers (manual implementation) or to go the UINavigationController route and have a completely separate view which would be activated i assume in the UINavigationController from the button event.

Cur开发者_开发问答rently my music and sound stuff is in a class attached to the "main" UIView in my game and initialised via ViewDidLoad.

Any advice would be greatly appreciated.


You should definitely put your menu code in a different view object. Don't just redraw the existing view in menu mode. That will make your code needlessly complicated.

You don't have to use UINavigationController to swap out one view for another, however. You write code yourself to remove the game view (removeFromSuperview) and add the menu view (addSubview:) to the application's window, using transition animations if you want.

You could also use UIViewController's presentModalViewController: method to push your menu view on top of the game view.

It's hard to say exactly what you need to do without knowing more about your code, but you should absolutely definitely keep different things as different classes, instead of making one class that acts as many things depending on a mode flag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜